views:

226

answers:

5

I have notice that stackoverflow.com does not have file extensions on their pages. How would I do this with an aspx web site?

+6  A: 

The URLs aren't actually pointing to files. They're using URL rewrite rules to convert the URL to a database query and feed the output back to a specified page (whose URL isn't displayed).

orthod0ks
Umm. Sort of. It actually invokes a controller action method, which probably does a db query and renders a particular view related to the url.
tvanfosson
+5  A: 

MVC

They use MVC

Pharabus
+6  A: 

Here's a great article from Scott Guthrie:

http://weblogs.asp.net/scottgu/archive/2007/02/26/tip-trick-url-rewriting-with-asp-net.aspx

It covers off all scenarios: IIS 6, IIS7, using third party URL rewriting tools, etc.

Nissan Fan
+4  A: 

Stack Overflow uses ASP.NET MVC which does clean URLs out of the box.

Basically what you need is something that takes the clean URL and then maps it to a standard .NET URL with your passing in extra 'directories' as parameters. e.g. rewriting /blog/post-no-one to /blog.aspx?id=post-no-one.

The new IIS has a rewrite plug in that will do this for you if you want to do it with traditional ASP.NET:

Using URL rewrite module

Or you can roll your own by overriding HttpModule and doing rewrites in there. Here is a complex example of that:

URL rewriting engine

Steve Temple
+1  A: 

As a few people have mentioned, SO is using the URL routing engine included with MVC. They've actually made the code available via CodePlex, so you can use it inside of a webforms-based ASP.NET site.

Phil Haack has a nice summary of how to do this:

Routing w/WebForms

It includes samples, links, etc. that should be helpful in getting you started.

Paul Mrozowski