Serving your ASP.NET .aspx pages with .html
Many SEO experts believe that Google prefers pages that end with the "html" extension. I’m guessing it has to do with the fact that static content is favored, because it is less commonly spammed. Even if Google doesn’t actually look at the extension, you certainly won’t be penalized for using the "html" extension.
To support a custom extension, my first thought was to put the following code in my web.config:
<compilation> <buildProviders> <add extension=".html" type="System.Web.Compilation.PageBuildProvider" /> </buildProviders> </compilation>
This wouldn’t be a bad way to do it, if not for the fact that ReSharper doesn’t like code for non-aspx files. I’m speculating that you may run into problems with other Visual Studio add-ins.
The alternative to use Server.Transfer by intercepting the requests, and transferring them to the correct page for processing.
Here is a basic example of an IHttpModule that will do the rewriting. I offer no guarantees with this code. In fact, I don’t use it anywhere in production (we use a full blown rewriter solution):
public class HtmlUrlRewriter : IHttpModule
{
private HttpApplication _context;
private void context_BeginRequest(object sender, EventArgs e)
{
string path;
path = _context.Request.Path;
if (path.EndsWith("html", true, CultureInfo.CurrentCulture))
_context.Server.Transfer(RewriteUri(_context.Request.Url).PathAndQuery);
}
public static Uri RewriteUri(Uri uri)
{
UriBuilder newUri;
newUri = new UriBuilder(uri);
newUri.Path = newUri.Path.Replace(".html", ".aspx");
return newUri.Uri;
}
#region IHttpModule Members
public void Init(HttpApplication context)
{
_context = context;
context.BeginRequest += context_BeginRequest;
}
public void Dispose()
{
}
#endregion
}
Of course you’ll probably have other types of requests that you are going to be rewriting, so I recommend coming up with a URL rewriter framework, or use one of the third party options that are available.
One last note. Before IIS will allow ASP.NET to handle the processing of html files, you need to add an application extension mapping. More information about configuring IIS mappings is available here.
Obishawn also has some more information about URL rewriting and postbacks on his blog.

Igor Loginov said,
Wrote on April 26, 2008 @ 4:29 am
Hi,
Seems, the easiest way is to use Global.asax :
protected void Application_BeginRequest(object sender, EventArgs e)
{
string url = Request.AppRelativeCurrentExecutionFilePath.Replace(“.html”, “.aspx”);
Context.RewritePath(url);
}
Sam said,
Wrote on April 28, 2008 @ 7:12 pm
This is probably the most useful article that I have seen today. However, I think a lot of hosts don’t allow custom HttpModules (I am not sure but I had a problem with that). In any case it would be useful in many scenarios.
frenky said,
Wrote on May 7, 2011 @ 7:02 pm
8EW97t http://gdjI3b7VaWpU1m0dGpvjRrcu9Fk.com