public class ProductHandler: IHttpHandler, IRequiresSessionState
{
public bool IsReusable
{
get { return true; }
}
public void ProcessRequest(HttpContext context)
{
context.Items[“originalQuerystring”] = context.Request.QueryString.ToString();
context.Items[“originalPathInfo”] = context.Request.PathInfo;
string productCode = {some code to derive your product code};
string page = “~/product.aspx”;
string queryString = “productCode=” + productCode;
foreach(string key in context.Request.QueryString.Keys)
{
if(key != “productCode“)
{
queryString += string.Format(“&{0}={1}”, key, context.Request.QueryString[key]);
}
}
context.RewritePath(context.Request.Path, string.Empty, queryString);
Page hand = (Page)PageParser.GetCompiledPageInstance(page, context.Server.MapPath(page), context);
// Listen for event to rewrite url back before the page renders.
hand.PreRenderComplete += new EventHandler(hand_PreRenderComplete);
hand.ProcessRequest(context);
}
void hand_PreRenderComplete(object sender, EventArgs e)
{
HttpContext.Current.RewritePath(HttpContext.Current.Request.Path,
HttpContext.Current.Items[“originalPathInfo”].ToString(),
HttpContext.Current.Items[“originalQuerystring”].ToString());
}
}