"在URL(冒号)甚至没有与requestPathInvalidCharacters工作= QUOT ASP.NET特殊字符; [英] ASP.NET special characters in URL (colon) not working even with requestPathInvalidCharacters=""
问题描述
我要在ASP.NET中的URL内通过一个冒号,如http://mywebapp.com/Portal:Main/。维基百科目前这个有很多,和冒号是根据RFC有效的URL字符。
I need to pass a colon within an URL in ASP.NET, like "http://mywebapp.com/Portal:Main/". Wikipedia does this a lot, and colons are valid URL characters according to the RFC.
我发现这个<一个href=\"http://stackoverflow.com/questions/2831142/asp-net-4-url-limitations-why-url-cannot-contain-any-3f-characters\">SO问题并通读<一个href=\"http://www.hanselman.com/blog/ExperimentsInWackinessAllowingPercentsAnglebracketsAndOtherNaughtyThingsInTheASPNETIISRequestURL.aspx\"相对=nofollow>这个博客帖子覆盖无效字符在ASP.NET进行过滤。
I've found this SO question and read through this blog post which covers the invalid characters filter in ASP.NET.
使用VS2010 Ultimate和一个新的ASP.NET WebForms和一个新的ASP.NET MVC 2的项目,我总是添加到了我的web.config尝试:
Using VS2010 Ultimate and trying with a new ASP.NET WebForms and a new ASP.NET MVC 2 project I always added this to my web.config:
<httpRuntime requestPathInvalidCharacters="" />
以及本
<httpRuntime requestValidationMode="2.0"
requestPathInvalidCharacters=""
relaxedUrlToFileSystemMapping="true"
/>
但尽管如此,我总是得到一个错误400:错误的网关时,用特殊字符像任何访问的http://本地主机:1分之2021%3As.aspx
或的http://本地主机:一分之二千〇二十一:s.aspx
这些项目肯定是使用.NET 4的运行时间。怎么回事错在这里?
The projects are definitely using .NET 4 runtime. Whats going wrong here?
推荐答案
我来回答这个问题我自己,因为我在此期间发现:
I'll answer the question myself as I found out in the meantime:
您必须翻转一个注册表开关,它的工作:
You have to flip a registry switch for it to work:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\ASP.NET
DWord Value Name: VerificationCompatibility
Value Data: 1
查看根据MS KB文章更多的细节。
有关单用户:该注册表值荣幸在Windows系统上。在非Windows系统中,你可以通过添加monoSettings部分你的web.config改变行为:
For mono users: the registry value is honored on windows systems. On non-windows systems you can change the behaviour by adding a monoSettings section to your web.config:
<monoSettings verificationCompatibility="1" />
<httpRuntime requestValidationMode="2.0"
requestPathInvalidCharacters=""
relaxedUrlToFileSystemMapping="true"
/>
这篇关于&QUOT;在URL(冒号)甚至没有与requestPathInvalidCharacters工作= QUOT ASP.NET特殊字符;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!