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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值