Archive

Archive for May, 2006

IIS Application Mapping

May 8th, 2006

‘Applications Extensions’ in IIS allows you to bind file extensions to ISAPI’s (for example the dot net framework). This allows you to create unique extensions for your applications, instead of using the traditional ‘.aspx’.

(IIS 6.0 was used at the time of writing this article. Unfortunately to date I haven’t been able to get this working on IIS7)

Example Use

There are several examples of where I have needed to use this. I tend to use it either to increase search engine optimisation through rewriting urls, or to add simple yet effective commands to users or administrators in the form of extensions (’.add’, ‘.delete’, ‘.edit’, ‘.move’ etc)

I’ve recently created a website which moderators can easily add or modify pages in a wiki type style. For ease of editing pages, and to not advertise to the rest of the world, all you need to edit a page is to add ‘.edit’ to the end of the URL.

If you are playing with ModRewrite, you will find binding wildcards can really prove invaluable. It allows you to completely remove the ‘.aspx’ at the end of the url, and replace it with any other extension you like, or remove it altogether like on this wiki.

Adding Application Extensions

In order to register custom extensions with IIS and allow it to pass these requests to the dot net framework, or any other ISAPI, you will need to do the following:

  • In IIS Manager, load up the properties page on the website in question.
  • Select the ‘Home Directory’ tab
  • Click on ‘Configuration’ to obtain the ‘Application Configuration’ dialog
  • Under Mappings, click ‘add’ to allow you to enter an alternative extension
  • Executable should be the dot net isapi, which is typically located as follows:

c:\winnt\microsoft.net\framework\v2.0.50727\aspnet_isapi.dll

  • Extension, well, the extension you wish, starting with a period.
  • If this is a dynamic page, ie, the page doesn’t actually exist on the server, but is handled at runtime, un-tick ‘verify that file exists’

IIS should now send the request to the framework, and you should be able to catch it within your application and deal with it however you see fit.

Wildcard application maps

If you have multiple extensions, or simply wish to remove the extension altogether, adding a wildcard will pass any requests not caught by the above mappings into the framework. This is extremely handy when rewriting urls.

Click insert, and add the isapi you require. When rewriting urls, you certainly want to un-tick the ‘Verify that file exists’ option to prevent a 404 from occurring; the physical file is called and probably located somewhere completely different.

Techie ,