I have the url: http://localhost:1714/Message/Index
我有url: http://localhost:1714/Message/Index
I want to show: http://localhost:1714/Message/Index.html
我想显示:http://localhost:1714/Message/Index.html
How can I do it?
我怎么做呢?
1 个解决方案
#1
2
You need to modify Web.config to map requests for your HTML files to TransferRequestHandler.
您需要修改Web。将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>
This is explained here by Jon Galloway.
Jon Galloway对此作了解释。
And put this to your RouteConfig:
把这个放到你的日常生活中:
public static void RegisterRoutes(RouteCollection routes)
{
...
routes.MapRoute("Default", "{controller}/{action}.html", new { controller = "Home", action = "Index" });
...
}
Than accessing http://localhost:{port}/Home/Index.html will send you to your Home page.
比访问http://localhost {港口} / Home /索引。html会将您发送到您的主页。
#1
2
You need to modify Web.config to map requests for your HTML files to TransferRequestHandler.
您需要修改Web。将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>
This is explained here by Jon Galloway.
Jon Galloway对此作了解释。
And put this to your RouteConfig:
把这个放到你的日常生活中:
public static void RegisterRoutes(RouteCollection routes)
{
...
routes.MapRoute("Default", "{controller}/{action}.html", new { controller = "Home", action = "Index" });
...
}
Than accessing http://localhost:{port}/Home/Index.html will send you to your Home page.
比访问http://localhost {港口} / Home /索引。html会将您发送到您的主页。