30. July 2008 00:01
Trying to rewrite URL's or custom handle URL's on IIS 6/7 can lead to HTTP errors on the IIS level.
The problem is that some characters like a question mark (?) are considered illegal by IIS when they are a part of a URL file name or path.
Will produce: HTTP Error 404 - File or directory not found, even if there is an HTTP handler defined for that file type.
Since those characters are not allowed by IIS, requests containing those characters are blocked on the Http.sys level before they ever reach the appropriate HttpHandler.
Unfortunately this means that ASP.Net code does not get a chance to handle URL's that contain characters dimmed illegal by IIS.
Currently the only solution is to change IIS registry settings that effect the way Http.sys handles those types of characters.
Specifically you will need to change the AllowRestrictedChars setting from 0 to 1.
The main problem with this solution is that if you don't have access to those registry settings you have a problem!
For example people using shared hosting solutions or shared servers where some sites want to allow this option and some don't will not be able to use this solution.
I hope this will change in future versions of IIS. in my opinion the AllowRestrictedChars option should be configurable per site through an ASP.NET configuration option.