Running .ashx files on IIS 7, Windows 7 and .NET 4

If you simply copy your Visual Studio 2010 generic handler (.ashx) project’s directory into a virtual directory on IIS it will fail with an error similar to the following:

Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.

Parser Error Message: Could not create type ‘HealthCheck.health’.

There are lots of suggestions on the internet, but the most fundamental fix is hard to find. I know because I’ve run into this problem before and it took me quite a while to figure it out. This time I only wasted a half-an-hour before a little voice in my head reminded me that generic handlers created in Visual Studio 2010 require that they be run as an application in IIS.

So here’s how you do set up IIS to run the .ashx file as an application:

  1. Open  Internet Information Services (IIS) Manager
  2. Double-click on “Application Pools”. If your Default App Pool is not set to v4.0 then double click on it and change the version. If you don’t have v4.0 installed, then you’ll you need to do so. NOTE: if you change this be sure to test your other/older applications to make sure they don’t break. If they do break other apps, then right click below the Application Pool table and create a new, custom app pool using .NET v4.0.
  3. Right click “Default Web Site”
  4. Select “Add Application”
  5. Fill in all the Alias and Physical Path fields. BE SURE to select the correct application pool referenced in step 2!!

Extras

  1. Here’ s a great blog post on how find your .NET version that’s being used: http://www.walkernews.net/2008/05/16/how-to-check-net-framework-version-installed/ .
  2. You can also look at the bottom of the Parser Error Message and you’ll see the .NET version there, as well.

Tags: , , , , , , , , ,

One Response to “Running .ashx files on IIS 7, Windows 7 and .NET 4”

  1. […] I have been trying to get a demo of jQuery File Upload working and have been faced with an error for the last couple of hours that I just can’t shake. The “could not create type ‘namesapce.myHandler’” error seems to be fairly common but from having a look around this seems to be the most helpful resource I could find: http://www.andygup.net/running-ashx-files-on-iis-7-windows-7-and-net-4/ […]

Leave a Reply