首页 > Web开发 > 详细

mvc 伪静态任意扩展名的实现方法

时间:2016-08-03 00:00:20      阅读:299      评论:0      收藏:0      [点我收藏+]

比如:要实现 http://localhost:60291/home/geta/1212.html 或者 .abc 任意扩展名

 

完成两步即可。

第一步修改路由:

   public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
            routes.MapRoute(
                 name: "2",
                 url: "{controller}/{action}/{id}.html",
                 defaults: new { controller = "Home", action = "Index",  }
             );
            
        }

第二步:修改web.config

增加

<system.webServer>节点 增加如下:
    <modules runAllManagedModulesForAllRequests="true"></modules>

mvc 伪静态任意扩展名的实现方法

原文:http://www.cnblogs.com/efreer/p/5731039.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!