我有网址:http://localhost:1714/Message/Index
我想展示:http://localhost:1714/Message/Index.html
我该怎么做?
您需要修改 Web.config 以将对 HTML 文件的请求映射到 TransferRequestHandler。
like so:
<system.webServer>
...
<handlers>
<add name="HtmlFileHandler" path="*.html" verb="GET" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
</handlers>
...
</system.webServer>
这是解释的here作者:乔恩·加洛韦。
并将其放入您的 RouteConfig 中:
public static void RegisterRoutes(RouteCollection routes)
{
...
routes.MapRoute("Default", "{controller}/{action}.html", new { controller = "Home", action = "Index" });
...
}
比访问http://localhost:{port}/Home/Index.html 将带您进入主页。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)