I'm having trouble doing what I want to achieve when doing routing in ASP.NET MVC. What I want to do is the following:
- When typing
http://localhost/MyWebsite/, I want to redirect tohttp://localhost/MyWebsite/Login/(The redirection to the actionIndexis implied here) - When typing
http://localhost/MyWebsite/MyAction, I want to redirect tohttp://localhost/MyWebsite/Login/MyAction
Point 1 was achieved using the following lines in the file RouteConfig.cs:
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Login", action = "Index", id = UrlParameter.Optional });
But I cannot accomplish point 2. Note that the user does not come from another action in a controller, but actually types the address in his browser.
Thanks for your help.