您的位置:首页 > 编程语言 > ASP

ASP.NET MVC 路由配置 管线模式伪静态

2015-07-23 09:22 253 查看
这种方法只能在iis7以上iis使用。

web.config 配置

<httpHandlers>
<add verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" path="*.html" type="System.Web.StaticFileHandler"/>
<add path="*" verb="*" type="System.Web.HttpNotFoundHandler"/>
</httpHandlers>

默认控制器 /控制器方法/参数

routes.MapRoute(
  name: "Default",
  url: "{action}.html",
  defaults: new { controller = "Home", action = "Index" }
);

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

加上控制器访问 控制器/控制器返回方法/参数

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

routes.MapRoute(
  name: "DefaultOptional",
  url: "{controller}/{action}/{id}",
  defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: