首先RouteConfig配置文件RegisterRoutes方法添加以下代码:
routes.MapMvcAttributeRoutes();
Controller Aciont 加
[Route("news/{id:long:min(1)}.html"), HttpGet]
在web.config文件system.webServer节点添加如下配置:
<system.webServer> <handlers> <add name="HtmlFileHandler" path="news/*.html" verb="GET" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" /> </handlers> </system.webServer>