using System.Web;
public class SimpleRewriter : System.Web.IHttpModule
{
HttpApplication _application = null;
public void Init(HttpApplication context)
{
context.BeginRequest += new System.EventHandler(context_BeginRequest);
_application = context;
}
public void Dispose()
{
}
private void context_BeginRequest(object sender, System.EventArgs e)
{
string requesturl =
_application.Context.Request.Path.Substring(0,
_application.Context.Request.Path.LastIndexOf("//")
);
string[] parameters = requesturl.Split(new char[] { '/' });
if (parameters.Length > 1)
{
string firstname = parameters[1];
string lastname = parameters[2];
_application.Context.RewritePath("~/unfriendly.aspx?firstname=" +
firstname + "&lastname=" + lastname);
}
}
}
|