Asp.Net Mvc MapRoute .html不起作用(转)

RegisterRoutes 注册路由示例配置:

public static void RegisterRoutes(RouteCollection routes)
{
    routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

    routes.MapRoute(
        name: "default",
        url: "controller/{id}.htm",
        defaults: new { controller = "Home", action = "Index" });
}

Controller 示例代码

public class HomeController : Controller
{
    // GET: Home
    public ActionResult Index(int id)
    {
        return View();
    }
}

解决方式在 Web.config 中添加如下配置:

<system.webServer>
  <modules runAllManagedModulesForAllRequests="true" />
</system.webServer>

 

posted @ 2016-05-13 22:36  天马3798  阅读(478)  评论(0编辑  收藏  举报