方式来定义一个ASP.NET MVC路线 [英] Ways to define an ASP.NET MVC Route
问题描述
我在想,如果你能告诉我所有的各种方式申报的ASP.NET MVC路线(1和2)。请解释定义的路由,它是如何使用的每个方法,什么情况下,它涵盖了。
I was wondering if you could show me all the various ways to declare routes in ASP.NET MVC (1 and 2). Please explain each method of defining a route, how it is used, and what case it covers.
下面是我希望能在这里收集的例子:
Here is an example of what I am hoping to collect here:
routes.MapRoute("Directors",
"Directors/{filter}/{skip}",
new { controller = "Directors", action = "Index", skip = 0, filter = "" },
new { skip = @"\d+", filter = @"^[a-zA-Z]+.+" });
董事
=路由的名称。 董事/ {滤} / {跳}
= URL定义。 新{控制器=董事,行动=索引,跳过= 0,过滤器=}
=默认的这条路。 新{跳过= @\\ D +,筛选= @^ [A-ZA-Z] + +}
=该路由的限制。
Directors
= the name of the route. Directors/{filter}/{skip}
= the url definition. new { controller = "Directors", action = "Index", skip = 0, filter = "" }
= the default for this route. new { skip = @"\d+", filter = @"^[a-zA-Z]+.+" }
= the constraints for this route.
推荐答案
我的第一个停靠港将是学习ASP.NET的页面上的路由。
My first port of call would be the ASP.NET learning pages on routing.
我想这也可能是一个很好的利用了社区维基功能,因为这个问题你问一个pretty模糊的问题,其中有没有真正的答案,航线上刚刚好文档。
I think this may also be a good use of the Community Wiki feature, as the question you're asking a pretty vague question where there are not real answers, just good documentation on routes.
这篇关于方式来定义一个ASP.NET MVC路线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!