ASP.NET MVC自定义路由龙自定义路由不点击我的头 [英] ASP.NET MVC Custom Routing Long Custom Route not Clicking in my Head

查看:176
本文介绍了ASP.NET MVC自定义路由龙自定义路由不点击我的头的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经花了几个小时今天在ASP.NET MVC做自定义路由读了。我能明白怎么做任何类型的自定义路由,如果它扩展或比缺省路由类似/小。不过,我想弄清楚如何做类似的路线:

I have spent several hours today reading up on doing Custom Routing in ASP.NET MVC. I can understand how to do any type of custom route if it expands from or is similar/smaller than the Default Route. However, I am trying figure out how to do a route similar to:

/Language/{LanguageID}/Question/{QuestionID}/

和我想的东西,也就是类似于怎么这么工作的。是这样的:

And what I would like, too, is similar to how SO works. Something like:

/Language/{LanguageID}/Arabic/Question/{QuestionID}/Some-Question-Title

在哪里阿拉伯语和有些个问题 - 标题可以是任何东西,因为真正重要的是ID的

Where "Arabic" and "Some-Question-Title" can be almost anything because what really matters is the ID's

一个完整的URL例子可能是

A complete url example might be

http://example.com/Language/22/Arabic/Question/135/What-is-the-importance-of-grammar

我要去超出了可以与扩展的URL过去的语言ID办?

Am I going beyond what can be done with the extended URL past the language ID?

推荐答案

您可以pretty多少做什么航线,但关键是要知道以何种顺序来注册它们。当MVC选择一个路线,它这样做,以便在它们被注册,并且相匹配的第一路线,是被选择的那个。

You can pretty much do anything with routes, but the key is knowing in which order to register them. When MVC selects a route, it does so in order in which they were registered, and the first route that matches, is the one that is selected.

这篇关于ASP.NET MVC自定义路由龙自定义路由不点击我的头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆