.net项目页面加.html无法访问

2020-12-10  本文已影响0人  默默前端路

.net默认路由不会添加.html,一般是www.xxxx.com/aa/bb
想要添加.html方法如下
1、路由添加

routes.MapRoute(  //话题页
    name: "testPage",
    url: "testPage/testPage.html",
    defaults: new { controller = "testPage", action = "test" }
);

2、在Web.config中添加

<system.webServer>
    <modules runAllManagedModulesForAllRequests="true" />
</system.webServer>

3、在iis中添加映射
iis面板---->找到处理程序映射-添加处理管理程序---->请求路径填*.html---->类型填System.Web.UI.PageHandlerFactory---->名称可以随意填写

PS:方法3的配置最好在服务器上面添加上,避免出现奇怪的问题

上一篇 下一篇

猜你喜欢

热点阅读