【发布时间】:2011-07-02 02:46:35
【问题描述】:
Global.asax.cs 的初始化代码如下:
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
);
我要问的是,它怎么知道它为“{controller}”得到的将是要调用的 Controller 类的名称?是否在某处定义了令牌?如果可以,我可以列出它们吗?
如果我定义了额外的标记(如“{lang}”),它会假定它们是额外的参数吗?
(我正在开发一个自定义 URL 重写/重定向处理程序,我需要它来使用 MVC...)
为 URL 定义自定义模式和“别名”最实用的方法是什么?
【问题讨论】:
标签: asp.net-mvc url url-rewriting asp.net-mvc-routing