[英]ASP.NET MVC Route Doesn't Work With .html Extension
我使用ASP.NET MVC开发了一个Web应用程序。 我的路线有问题。
我需要这样的路线。 http://localhost/content-name/23.html
我为此定义了一条路线
//i need this route but it's not work
routes.MapRoute(
"GetContent",
"{sefLink}/{contentId}.html",
new { controller = "Content", action = "GetContent" },
new[] { "CanEcomm.Controllers" });
但是这条路线不起作用。 IIS向我显示404页面。 当我删除.html扩展名时,路由可行。
//this route is working. i just remove ".html" extension
routes.MapRoute(
"GetContent",
"{sefLink}/{contentId}",
new { controller = "Content", action = "GetContent" },
new[] { "CanEcomm.Controllers" });
我该如何解决? 谢谢
我已经将HtmlFileHandler添加到我的web.config中。 .html路由现在可以使用。
<handlers>
<add name="HtmlFileHandler" path="*.html" verb="GET" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
</handlers>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.