ASP.NET MVC 路由配置 管线模式伪静态
这种方法只能在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 }
);