一开始真被这个问题难住了,后来换了个思路解决了:
routes.MapRoute( name: "mylist", template: "{go_to}.html", defaults: new { controller = "Test", action = "List" }, constraints: new { go_to = @"(go)?_(to)?" });
果然大神啊,请受我一拜!
routes.MapRoute( "mylistnew", "{go_to}.html", new { controller = "Test", action = "List" }, new { go_to = "([a-zA-Z]*)_([a-zA-Z]*)" } );
根据dudu大神的代码改了下,可以使用。
感谢dudu!
先确定你的规则,再去写,路由只会跟着你的规则走,你了设定你的默认a或者默认b