In a hosted IIS7 environment, I am looking for the simplest way to use extension-less file names. Simply I have the following pages:
index.html (or .aspx) --> domain.com gallery.html --> domain.com/gallery videos.html --> domain.com/videos etc...
I only have a handful of pages, I have no dynamic code, nothing special. All the examples I have found or methods I use in other sites I've developed revolve around dynamic content, pages, etc. I am simply looking for the simplest solution, ideally not requiring any sort of url rewrite module installed. Preferably, I could keep the .html extension instead of converting the site to a ASP.NET project, but that is an option.
Thanks.
You can do this in c# to use a customized extension in your URL in ASP.NET.
Let ".recon" in the code be your customized extension. (i.e replace ".recon" to your own extension)
If you have dynamic code, I think that the easiest thing to do is to just rename the files from .aspx to .html especially if you only have a handful of pages. There is no simple way to do it without rewriting the URL somehow.
However, with IIS 7, you can set it up really easily with an HTTP Module. Scott Guthrie explains this really well. In this post, he shows several approaches to customizing the URLs. I think that you would like approach #3 the best.
http://weblogs.asp.net/scottgu/archive/2007/02/26/tip-trick-url-rewriting-with-asp-net.aspx
I don't have enough points to comment, and this is improving Pawan M's answer. His will work, unless you have Query Strings being used on the page. I have modified Pawan's code to allow for query strings, not to mention mine is the vb version.
Check to make sure your project has a Global.asax.vb file in it. If it doesn't Add an Item by doing this:
File -> New -> File -> Global Application Class
In the Global.asax file of your project add this function:
Another simplest solution for achieving the same:
Put following lines of code into your global.ascx file:
I ended up using the following sites:
http://blogs.msdn.com/b/carlosag/archive/2008/09/02/iis7urlrewriteseo.aspx
and
http://forums.iis.net/t/1162450.aspx
or basically the following code in my web.config file using the IIS7 URL Rewrite Module that most hosted sites now offer (in this case I am using GoDaddy):
Another little bit more modern way to do this is using Microsoft.AspNet.FriendlyUrls. In the Global.asax.cs add:
and in the RouteConfig file