public static void RegisterRoutes(RouteCollection routes) { string suffix = string.Empty; routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); var temp = new System.Text.StringBuilder(); var methods = typeof(Web.Controllers.HomeController).GetMetho…
MapRoute(RouteCollection, String, String) 映射指定的URL路由. 'Declaration <ExtensionAttribute> _ Public Shared Function MapRoute ( _ routes As RouteCollection, _ name As String, _ url As String _ ) As Route routes 应用程序的路由集合 name 要映射的路由的名称. url 路由的URL模式.…
3.自定义路由约束 什么叫自定义路由约束呢?假如路由格式为archive/{year}/{month}/{day},其中year,month,day是有约束条件的,必须是数字,而且有一定范围. 这时候,我们就可以设置约束类,进行自定义路由约束了. 第一步: 我们先添加年份限制类 YearRouteConstraint.请看代码: using System; using System.Collections.Generic; using System.Linq; using System.Web;…