all posts

Custom File Extensions for ASP.NET files in IIS

Published to Blog on 27 Aug 2004

I’ve been working on a site where we’d like to rename the “.aspx” files to something else, like “.wxyz“.  The primary reason we want to do this is not to hide the fact that the application is built on Microsoft technology, but we don’t want to blatantly advertise it.  The organization we built it for is a little sensitive to things like that.  It would be an understatement to say that they have standardized on another platform.  But I was able to build them a little application using ASP.NET in 1/4 the time and at least a 75% savings of what could have been done using their preferred technology.  So, you have the background.

I thought that the best solution would be to change the file extensions to .html and then map them in IIS so that they run through the aspnet_isapi.dll and are served up like regular .aspx pages.  For some reason that did not work, though.  I know that you could do that with ASP, so I assumed I could do it with ASP.NET as well.

I added the file extension and mapped it to the aspnet_isapi.dll in IIS and I added an httpHandler line in web.config to allow .html pages to be handled by PageHandlerFactory.  According to everything that I read, it should have worked, but it didn’t.  It just served up the HTML part of the page as HTML and served up the code as text (you could see it by viewing the source).  I tried restarting the site and rebooting the server and nothing - still the same results.

I decided to change the file extension to .htmlx and made all the necessary updates in IIS and my web.config file, restarted the site and later rebooted the server.  Now all the contents of the file (the code) were now being displayed on the page as if it were a text file.  Weird.  I couldn’t figure out what was wrong.

Finally, I changed the extension to .wxyz and made the necessary updates in IIS and my web.config file and it began working as expected.  Now I am really perplexed.

Can I not get files with a .html extension to be processed by the ASP.NET engine?  And even if you can’t do it with .html files, why couldn’t I get it to work with a .htmlx extension?

Please let me know if you’ve run into any other similar experiences.

BTW, once I got the .wxyz file extension working, I was able to get VS.NET 2003 to treat .wxyz files as if they are .aspx pages by using the VBTweak utility.

Dan Hounshell
Web geek, nerd, amateur maker. Likes: apis, node, motorcycles, sports, chickens, watches, food, Nashville, Savannah, Cincinnati and family.
Dan Hounshell on Twitter