MVC 伪静态路由

定义URL

@Html.ActionLink("html""Get_Page"new { id=1})

这URL是调用本控制器下面的的Get_Page方法,传参id

定义路由

routes.MapRoute(
                name:"UrlHtml",
                url:"{controller}/{action}/{id}.html"
                );

注册路由

RouteConfig.RegisterRoutes(RouteTable.Routes);

完成以上三点还需要配置webconfig,需要在system.webServer这个节点下面加上<modules runAllManagedModulesForAllRequests="true"></modules>

在ASP.net中的web.config中,modules的这个属性比较重要。由于是在Global.ascx中,如想对每个Request都执行Application_BeginRequest,那么必须要在system.web或system.webServer中的modules中加入此属性:

<modules runAllManagedModulesForAllRequests="true">

参考:http://blog.163.com/qfj_why/blog/static/195251321201401453449736/

        http://learn.iis.net/page.aspx/121/iis-7-and-above-modules-overview/

原文地址:https://www.cnblogs.com/theMaxBear/p/3837442.html