Rewrite URL and HttpHandler problems on IIS with certain character types

by APIJunkie 7/30/2008 12:01:00 AM

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.

 

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

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

Add comment


(Will show your Gravatar icon)  

  Country flag





Live preview

11/19/2008 7:01:55 PM

Powered by BlogEngine.NET 1.2.0.0
Theme by Mads Kristensen

About the author

Name of author

My name is Bacon…James Bacon.

I am an API wars veteran I was wounded by x86 assembly, recovered and moved on to C. I am currently stuck in C++ and sniffing .NET.

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.

E-mail me Send mail


Calendar

<<  November 2008  >>
MoTuWeThFrSaSu
272829303112
3456789
10111213141516
17181920212223
24252627282930
1234567

View posts in large calendar

Recent comments

Authors

Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2008

Sign in