Question

Mentioned stackoverflow only as an example, but if you look above the URL for ask is

http://stackoverflow.com/questions/ask

which means /ask is a subdirectory, but they also do this for the specific question pages. How do you code this in .NET?

Not a code question as much as a technique. I know this is great for SEO, but how do you create a site so that every "page" is its own directory? Dynamically.

Do you have a template or a hidden redirect???

How?? :)

Was it helpful?

Solution

It's termed URL rewriting:

Url Rewriting with ASP.NET

MSDN: URL Rewriting in ASP.NET

EDIT: As @Justice points out, StackOverflow uses Routing.

OTHER TIPS

StackOverflow uses something called Routing, which comes with .NET 3.5 SP1. Routing is a popular feature of a number of MVC frameworks, such as ASP.NET MVC, Ruby on Rails, and a number of Python and PHP frameworks.

Stack Overflow was built using ASP.NET MVC which uses a technique called Routing, see:

What Was Stack Overflow Built With?

and Routing

Stack Overflow uses ASP.net MVC

MVC uses the URL + Query String to determine the content, so its not like a URL which points to a specific page, but more like a hierarchical path to the properties of some data to be displayed

E.G. https://stackoverflow.com/users/[Put User ID Here]/[Put User Name Here]

prompts the website to display a USER with an ID specified in the path ( in this case the user name is probably just for kicks ) as opposed to a specific page created just for that user.

I have seen this accomplished by simply creating a folder for every web page and then having each folder contain a Default.aspx document (Assuming Default.aspx is setup as a default document in IIS, which it is by default). Then you can navigate to any folder on the site without specifying the page (Default.aspx).

For the dynamic part, I have worked with CMS systems that do it this way and the Default.aspx page simply inherits from some master template and the CMS system utilizes the ASP.NET rendering enginge to dynamically complete the web page.

Using folders may be a little heavy with the site structure, but it is an easy way to eliminate the page names from the browser.

This is how I structure my website and avoid having to use page names... for example http://www.innovaapps.net/Blog simply brings up the default.aspx page without having to specify the page name.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top