[英]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.