In my globas.asax file i have one register route
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Authentication", action = "BigClientLogin", id = UrlParameter.Optional } // Parameter defaults
);
and in my action "BigClientLogin" it redirects to a new action called "NewLogin". So at present my current url looks like "http://localhost:65423/Authentication/NewLogin" .But i need my url in "http://localhost:65423/Login" format. To change action name from "NewLogin" to "Login" is not possible since i called this action many places in my solution. So is there any alternative solution for this in mvc routing? or is this is not possible and better will be to change my action name?
A couple of options:
First, would be to map a route for this new login action:
Another option, if enabled, would be to leverage Attribute routing:
(Just make sure
routes.MapMvcAttributeRoutes()
has been called inRouteConfig.cs
)With either of these, you'll have a named route you can reference in your solution (which will allow you to change it in the future if necessary):
You can try action aliases defined as attributes, see the article for further details: http://haacked.com/archive/2008/08/29/how-a-method-becomes-an-action.aspx/
Easy - Put this before the default route above:
A simple solution would be using the ActionName attribute. just put this on your action method
this would change only the Action Name, if you want only the path to be /login, use the Route attribute: