ASP.net URL Rewrite

liunx

Guest
I have been working with an HttpModule so that it will catch all queries in the
BeginRequest Event, the module is registered to the root of the website. However it fails with 404's even if explicitly defining a HttpContext.Current.RewritePath("");. If I configure IIS 6 to use map all requests through the ASP.net engine it works half way. But stops FrontPage extensions from running.



using System;
using System.Web;
using System.IO;

namespace Purl
{

public class PurlRewrite: System.Web.IHttpModule
{
public PurlRewrite()
{

}



public void Init(System.Web.HttpApplication Appl)
{
Appl.BeginRequest += new System.EventHandler(Rewrite_BeginRequest);
}

/// <summary>
/// Dispose is required from the IHttpModule interface
/// </summary>
public void Dispose()
{
//make sure you clean up after yourself
}

/// <summary>
/// To handle the starting of the incoming request
/// </summary>
/// <param name="sender"></param>
/// <param name="args"></param>
public void Rewrite_BeginRequest(object sender, System.EventArgs args)
{
HttpApplication app = (HttpApplication)sender;
app.Context.RewritePath("~/Default.aspx");
}


}
}


the above is the code.
 
Back
Top