如何在URL asp.net mvc的4添加扩展的.html? [英] How add extension .html in url asp.net mvc 4?
本文介绍了如何在URL asp.net mvc的4添加扩展的.html?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我要展示:
的http://本地主机:1714 /消息/ index.html中
我该怎么办呢?
推荐答案
您需要修改Web.config文件为HTML文件的请求映射到TransferRequestHandler。
You need to modify Web.config to map requests for your HTML files to TransferRequestHandler.
像这样:
<system.webServer>
...
<handlers>
<add name="HtmlFileHandler" path="*.html" verb="GET" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
</handlers>
...
</system.webServer>
这是解释<一个href=\"http://weblogs.asp.net/jongalloway/asp-net-mvc-routing-intercepting-file-requests-like-index-html-and-what-it-teaches-about-how-routing-works\"相对=nofollow>由Jon加洛韦这里。
和把这个你RouteConfig:
And put this to your RouteConfig:
public static void RegisterRoutes(RouteCollection routes)
{
...
routes.MapRoute("Default", "{controller}/{action}.html", new { controller = "Home", action = "Index" });
...
}
不是访问的http://本地主机:(港口)/Home/Index.html会送你到你的首页
Than accessing http://localhost:{port}/Home/Index.html will send you to your Home page.
这篇关于如何在URL asp.net mvc的4添加扩展的.html?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文