Reputation: 6814
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.
I've found this SO question and read through this blog post which covers the invalid characters filter in ASP.NET.
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="" />
as well as this
<httpRuntime requestValidationMode="2.0"
requestPathInvalidCharacters=""
relaxedUrlToFileSystemMapping="true"
/>
But still, I always get a Error 400: Bad Gateway when accessing anything with a "special character" like http://localhost:2021/1%3As.aspx
or http://localhost:2021/1:s.aspx
The projects are definitely using .NET 4 runtime. Whats going wrong here?
Upvotes: 3
Views: 1847
Reputation: 6814
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
See the according MS KB Article for more details.
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"
/>
Upvotes: 4