问题描述
我实施ASP.NET MVC定制的控制器和的真正的希望能够在URL来使用冒号,这样我可以识别类/列的名字和他们的价值观,像所以:
I'm implementing a custom controller in ASP.NET MVC and really want to be able to use a colon in the urls, so that I can identify class/column names and their values, like so:
...但显然ASP.NET或IIS不允许在URL中冒号。我做了一些挖掘,显然它认为是一个安全问题,的但的,我使用MVC和我处理的所有的URL路径手动(只是把它们当作字符串),而不是它们涉及到文件系统,所以我pretty肯定,这并不适用。
...but apparently ASP.NET or IIS doesn't allow colons in urls. I did some digging and apparently it's considered a security issue, but, I'm using MVC and am handling all url paths manually (just treating them as strings), and not relating them to the file system, so I'm pretty sure this doesn't apply.
我也听到一些谈论实现自定义HTTP处理程序或东西。
I also heard some talk about implementing a custom Http handler or something.
任何想法或意见将是非常美联社preciated。
Any thoughts or ideas would be much appreciated.
呃....为什么?严重的是,为什么打破标准? - Randolpho
...
我建议的话,您调查构建Web服务。 WCF是一个很好的技术是什么,以及它在IIS托管很好。
我碰巧喜欢的URL,而WCF是太复杂,我的目的。我想这是网址兼容,如休息,但能够不仅仅是导航层次结构,或者做好下岗了的东西。我有一个/用户/ chaiguy的问题是,这是间preting层次那里是没有:在我的系统用户是一类,它不是一个文件夹。用户:chaiguy意味着chaiguy的值的用户类的实例,这是一个单一的实体,即具有儿童实体的潜力。因此,例如:
I happen to like urls, and WCF is way too complicated for my purposes. I want it to be url-compatible, like REST, but capable of more than just navigating hierarchies, or doing well laid-out things. The problem I have with /users/chaiguy is that it is interpreting hierarchy where there is none: in my system "user" is a class, it's not a folder. user:chaiguy means the instance of the user class with the value of "chaiguy", and that is a single entity, that has the potential of having child-entities. So for example:
/用户:chaiguy /名称
...我想显示实体的名称。如果我这样做你的方法,它是这样的:
...I would like to display the name of that entity. If I did this with your method, it would look like this:
/用户/ chaiguy /名称
问题是你怎么知道什么是类,什么是价值?这可能是因为PTED间$ P $
The problem is how do you know what's the class and what's the value? It could be interpreted as
/用户/ chaiguy:名称
在我的系统,那没有意义。明白我的意思吗?为了给出一个稍微复杂一点的例子,假设我们要选择的用户实体的一个子出多个实例。因此,用户可能有多个电子邮件地址。要选择一个,我们可以使用:
in my system, and that doesn't make sense. See what I'm getting at? To give a slightly more complicated example, suppose we want to select a child of the user entity out of multiple instances. So a user might have several email addresses. To select one, we might use:
/user:chaiguy/email:[email protected] /
所以它实际上是递归的。这不是一个文件路径,它更像是一个XPath(或者类似的jQuery基于什么小我知道它尚未)。也就是说,这是更动态评估查询选择比硬连线文件路径。它获取服务器上进行评估。
So it is in fact recursive. It's not a file path, it's more like an XPath (or maybe similar to jQuery based on what little I know of it yet). That is, it's more of a dynamically-evaluated query selection than a hardwired file path. It gets evaluated on the server.
请不要误会,我不是建设一个典型的Web网站,甚至Web服务在这里。
Make no mistake, I'm not building a typical web site or even web service here.
推荐答案
更改的httpRuntime
的 requestPathInvalidCharacters
属性web.config中:
Change the requestPathInvalidCharacters
attribute of httpRuntime
in web.config:
<httpRuntime maxRequestLength="20480" requestValidationMode="2.0" requestPathInvalidCharacters="" maxQueryStringLength="20480" />
和ASP.NET不应该再从你的请求路径阻断冒号。
and ASP.NET should no longer block colons from your request path.
这篇关于在ASP.NET/IIS一个URL中使用一个冒号(:)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!