ASP.NET MVC2 中一个路由的细节问题

我们一般可设置路由信息:

 

代码
MapRoute("ShowUrl",
         
"Auth/RoleGroup/{templateid}",
         
new
         {
          controller 
= "Auth",
          action 
= "roleGroup",
          templateid 
= UrlParameter.Optional
        }
 );

 

 

那么在访问时,可以直接输入:http :  //localhost/myweb/auth/rolegroup/1001

那么,我的controller中的定义的ACTION的名字是 RoleGroup

如果,你在上面的路由定义中,你没有按大小写来拼写 rolegroup。

那么,http :  //localhost/myweb/auth/rolegroup/1001 这个地址,不会把1001值传递给{templateid},

如果在其它的ACTION中使用

return RedirectToAction("RoleGroup"new { templateid });

 

 

如果前面的路由设置中ACTION的动作 roleGroup 与 CONTROLLER 中的动作 RoleGroup 有大小写不一至的话;

执行的结果是:

 http :  //localhost/myweb/auth/rolegroup?templateId = 1001

 

如果前面的路由设置中ACTION的动作 roleGroup 与 CONTROLLER 中的动作 RoleGroup 有大小写一至的话;

 

执行的结果是:

 http :  //localhost/myweb/auth/rolegroup/1001

 

 

 

posted @ 2010-10-20 14:52  OpenSchema  阅读(728)  评论(3编辑  收藏  举报