本文介绍了ASP.NET MVC路由 - 添加.html扩展路线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是pretty新的MVC和路由,我被要求修改一个应用程序来使用不同势的URL。
一个任务就是有点超过我,因为我没有经验。

i am pretty new to MVC and Routing and i was asked to modify an app to use diffrent url's.a task that is a bit over me since i have no experience.

好吧,让我们谈点code的:

ok, lets talk a bit of code:

routes.MapRoute(
"CategoryBySeName", // Route name
"products/{SeName}", // URL with parameters
new { controller = "Catalog", action = "CategoryBySeName" }
);

这正常工作,但客户希望。html的在路径的终点,所以我改变:

this works as expected, but then the client wanted ".html" at the end of paths, so i changed:

"products/{SeName}", // URL with parameters

"products/{SeName}.html", // URL with parameters

而失败(IIS 404页 - 马prequestHandler)
好像IIS试图加载具有该名称的物理文件,而不是将它传递给应用程序。

which fails ( IIS 404 page - MapRequestHandler)it seems like iis is trying to load a physical file with that name instead of passing it to the application.

相似:(没有回答,不重复)

Similar: ASP.NET MVC Routing to start at html page (not answered, Not duplicate)

推荐答案

更改应用程序池由古典向综合固定的问题。
谢谢你guyz的帮助。

Changing the Application Pool from Classic to Integrated fixed the issue.thank you guyz for your help.

这篇关于ASP.NET MVC路由 - 添加.html扩展路线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-14 20:09