【发布时间】:2015-02-25 10:18:00
【问题描述】:
我喜欢创建这样的注册路线:
User/{^[a-zA-Z]+$}/{controller}/{action}/{id}
这就是 URL 的样子:
/User/myUser/Product/Action
所以我在 AreaRegistration 中注册了一条路线。约束应该只允许单词。
context.MapRoute(
"Customer_Default",
"User/{^[a-zA-Z]+$}/{controller}/{action}/{id}",
new { action = "Index", id = UrlParameter.Optional }
);
- 我的约束是否正确。
- 如何使用
RedirectToAction路由重定向到此? - 在操作中获取用户名的最佳方式是什么?正则表达式...?
【问题讨论】:
标签: c# regex asp.net-mvc asp.net-mvc-4