Alex Rivera | Logout

How do .NET sites hide .aspx extension of their files?

Asked 2008-10-21T22:22:55.460
32

I'm pretty sure stackoverflow.com is created with ASP.NET, but no matter where I click I see no .aspx extension in the address bar. How it is done and is there a particular reason for this?

Edit
Report

1 Answer

3

You can do this and more with ISAPI rewrite (for IIS). It allows you to create friendly urls without all the ugly query strings. It gives users a friendlier interface and can make your content more searchable.

If you are using Apache, use mod_rewrite.

The basic premise of both is that they take a friendly url (like the one you see for this site), then they transform it using a series of rules (typically regexs that you specify) to internal urls or query strings that are easily understood by the code.

An example would be that they convert posts/edit/<postnumber> to editPost.aspx?postNumber=<postnumber> by using a transform rule.

answered 2008-10-21T22:25:18.700

Your Answer