Thursday, March 17, 2005

URL Rewriting

You can redirect users to a URL by using URL Rewriting in ASP.NET. To accomplish this, you can use a HttpModule that Scott Mitchell wrote to perform the redirects based on mapping rules configured in web.config for the web application. His article on this is here: URL Rewriting with ASP.NET

One thing that you might want to do is to allow users to navigate your site by using directory-only URL's like this: http://localhost/Products, which should redirect them to the http://localhost/Products/inventory.aspx page. IIS processes requests for directory-only URLs by first determining if the directory exists, and if it does, it then checks to see if the directory contains a default document. By default, the following files are default documents for directories: default.htm, default.asp, index.htm and iisstart.asp. If the directory does not contain one of the default files, IIS will issue a 403 Forbidden error. To require IIS to process the directory request for a directory that only contains the default.aspx file, you will need to add the default.aspx document to the default documents property via the property page for the virtual directory. Once this is done, you can add a rule to redirect /Products/default.aspx to /Products/inventory.aspx as described in Scott's article.

Comments: Post a Comment



<< Home

This page is powered by Blogger. Isn't yours?