Siyah�n Sadeli�i...

Converted by MaidZoe

IIS 6.0 does not support URL Rewriting, directly. But writing your own HttpHandler, you specify meanful URLs for your web application. That feature gives much more information to Search Engines ( especially Google ) about your page.


In the scenario, we publish articles from the our pages. And we do not want URLs ( like .../default.aspx?id=445 ).


public void Page_Load(object sender,System.EventArgs e)
string sId = Request.QueryString("id");

//Connect database and Get Data with sID
// We just simply write sId on the page


and then we implement IHttpHandlerFactory interface

public class myHandler : IHttpHandlerFactory

public IHttpHandler GetHandler(HttpContext context, string requestType, string url, string pathTranslated)

int s1 = context.Request.RawUrl.LastIndexOf("/");
int s2 = context.Request.RawUrl.LastIndexOf(".");

// we find id section of the requested URL ( )
string sID = context.Request.RawUrl.Substring(s1 + 1, s2 - s1 -1);

//Then rewrite the URL Path of the context
context.RewritePath(context.Request.RawUrl + string.Format("?id={0}", sID));

//Call the page which execute the code by using sID
return PageParser.GetCompiledPageInstance("~/default.aspx", pathTranslated, context);


IIS Settings
Open properties window of your application. From configuration section, add new extension which is be handled by aspnet_isapi.dll

download the source