Simple URL ReWriting/Mapping in IIS7

Posted: April 6, 2011 in Programming & Development
Tags: , , ,

There’s an easy alternative to other over-complicated solutions on the web if your mappings are simple/static and/or you have a spare grunt to quickly and easily keep them updated without having to write a line of code.

In web.config add:

  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true" />
  </system.webServer>

Under system.web add static mappings like so:

<urlMappings enabled="true">
			<add url="~/default" mappedUrl="index.aspx"/>
			<add url="~/login" mappedUrl="login.aspx"/>
			<add url="~/logout" mappedUrl="logout.aspx"/>
</urlMappings>

Voila.

Of course some scenarios require more complex mappings, but for most non-ecomm/non-web app sites and even blogs this solution would work np, be faster to maintain without requiring assembly publishes and is less error-prone.

Comments

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s