Setting up IIS 7 to handle sitmap.xml request in code.

Recently I created a sitmap generator that worked on the fly - so that when the sitemap.xml was requested it got the latest from the database.  In the development environment this worked fine, however when I put it on IIS 7 it kept giving a 404 file not found error.  Obviously the .xml extension wasn't being mapped to the .net framework.  This used to be a lot easier in IIS 6, but took me a little while to figure out in IIS 7.  Its not difficult, but you just need to know what to do.

  1. Open up the site configuration for IIS 7 and select "Handler Mappings".

  2. Click "Add Managed Handler..." in the top right corner.

  3. Put request path as "sitemap.xml", Type as "System.Web.DefaultHttpHandler" and Name as "sitemap.xml".

  4. Ensure Request Restrictions has "invoke handler only if request is mapped" unchecked.

  5. Click Ok.
  6. Voila - it should now be working.


Add comment

(Will show your Gravatar icon)

  Country flag

  • Comment
  • Preview

About Me

I am 27year old living in London.  Director of Development for an online technology/marketing company - Intuitive Search Technologies.