比如:我有一个路由表,
route.MapRoute("MyRoute","{controller}\{action}/{id}",new {controller="Home",action="Index",id=UrlParameter.Optional});
然后在view当中使用了这个出站路由:
<div>
@Html.ActionLink("this is an outgoing URL","CustomeVariable");
</div>
此时的html变为:<a href="/Home/CustomeVariable">this is an outgoing URL</a>
但是如果,添加一个路由,如:
route.MapRoute("NewRoute","{app/do{action}",new {controller="Home"});
route.MapRoute("MyRoute","{controller}\{action}/{id}",new {controller="Home",action="Index",id=UrlParameter.Optional});
此时的html变为:
<a href="app/doCustomeVariable">this is an outgoing URL</a>
能不能讲讲这是为什么?
这不就是路由了。。。。。
你的@Html.ActionLink("this is an outgoing URL","CustomeVariable");应该会匹配搭到route.MapRoute("NewRoute","{app/do{action}",new {controller="Home"})这个路由规则,但是你这个路由规则大括号不匹配不知道你哪漏写了。{app/do{action}里的app/do没有特殊含义就做字符串输出,而你的action是CustomeVariable所以有href="app/doCustomeVariable"。