且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

创建具有asp.net MVC和RouteUrl网址

更新时间:2023-11-26 17:02:46

的规则的顺序,使培训就业处。尝试插入此规则为第一位。

The order of the rules makes sence. Try to insert this rule as first.

此外,如果不要忘记需要定义约束 - 这将带来更好的规则匹配:

Also dont forget to define constraints if needed - it will results in better rule matching:

routes.MapRoute(
    "GigDayListings",                                // Route name
    "gig/list/{year}/{month}/{day}",                // URL with parameters
    new { controller = "Gig", action = "List" },    // Parameter defaults
    new
        {
            year = @"^[0-9]+$",
            month = @"^[0-9]+$",
            day = @"^[0-9]+$"
        }    // Constraints
);