Breaking changes in ASP.Net 2.0 HTTP Handlers when moving from IIS5 on Windows 2000 to IIS6 on Windows 2003

by APIJunkie 11/14/2007 11:27:00 PM

 If you use http handlers you might run into the same problem we had.

 On ASP 2.0, IIS 5, Windows 2000 the default http handlers are called automatically when they are not handled by your handler.

 On ASP 2.0, IIS 6, Windows 2003 the default http handlers do not get called and you receive a page error or missing content on your page depending on the content type.

 Example of problem:

 Let’s assume you have an HTTP handler that is configured in your web config file like this:

     <httpHandlers>

      <add verb="GET" path="ab*.jpg" type="WebLib.JPGHTTPHandler,WebLib"></add>

    </httpHandlers>

 The above handler will get called every time an “ab*.jpg” file will be requested.

That is to say a file that starts with “ab” and has the extension “.jpg”.

 On IIS 5 when a file that has a “.jpg” extension and does not start with “ab” is requested, it will be handled by a default ASP.NET handler.

 On IIS6 you will receive an error (in this case. jpg images will be missing from the requested page).

 One way to solve this is to explicitly tell ASP.NET to call the ASP.NET static file handler for every file that has the same extension but is not handled by our handler.

     <httpHandlers>

      <add verb="GET" path="ab*.jpg" type="WebLib.JPGHTTPHandler,WebLib"></add>

      <add verb="GET" path="*.jpg" type="System.Web.StaticFileHandler"></add>

    </httpHandlers>

 Note that the order of handlers in the above example is important. You should put the static file handler after your custom one! If you don’t, your handler will not get called, only the static file handler will get called for all .jpg files.

 You can find more information about the problem and possible solutions at: http://support.microsoft.com/Default.aspx?kbid=909641

 

Be the first to rate this post

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

Tags:

IIS | .NET

Comments

Add comment


(Will show your Gravatar icon)  

  Country flag





Live preview

11/19/2008 7:23:13 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