In the ASP.net webform many people have done through URL rewrite so that the URL does not have a suffix, this time we do exactly the opposite. Suppose we need to set the URL suffix to shtml to create the default project for the new ASP.net MVC project as an example. If you want to access the landing page, the URL matches the login Action for the Http://localhost/Account/Login,Account matching account controller,login. If we want to change the URL to http://localhost/Account/ Login.shtml, the action becomes login.shtml without changing the route, obviously unable to find this action, so there is a 404 error, we have to do is still resolve the action to login, so we will be the default route change to
1routes. Maproute (
2 "Default",
3 "{controller}/{action}.shtml",
4 new{controller= "Home", action= "I Ndex ", id=" "}
At this point, login in login.shtml is exactly the corresponding {action} so it will invoke the login action in account controller, which is our goal. If you want to use a different suffix, simply change. shtml to. aspx or. html.