Rewrite URL and HttpHandler problems on IIS with certain character types

by APIJunkie 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.

Example:

http://www.mydomain.com/MyUrlWithQMark?.ashx

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.

 

Tags:

IIS | .NET | Web Development

Comments

7/30/2008 12:17:32 AM #

trackback

Trackback from DotNetKicks.com

Rewrite URL and HttpHandler problems on IIS with certain characters

DotNetKicks.com

Comments are closed

About the author

Name of author

I was first wounded by x86 assembly, recovered and moved on to C. Following a long addiction to C++ and a short stint at rehab I decided to switch to a healthier addiction so I am now happily sniffing .NET and getting hooked on Silverlight.

I am mainly here to ramble about coding, various API’s, Junkies(me especially) and everything else that happens between coders and their significant other.

  James Bacon