
 protected void Application_BeginRequest(Object sender, EventArgs e)
protected void Application_BeginRequest(Object sender, EventArgs e)  {
{
 
        
 string strCurrentPath;
        string strCurrentPath;
 strCurrentPath = Request.Path;
        strCurrentPath = Request.Path;
 //make sure that it ends with aspx.  This is some quick validation on the path.
        //make sure that it ends with aspx.  This is some quick validation on the path. 
 //This will shortcut processing for images and other files (WebResource.axd, for example).
        //This will shortcut processing for images and other files (WebResource.axd, for example). 
 if(System.IO.Path.GetExtension(strCurrentPath).EndsWith(
        if(System.IO.Path.GetExtension(strCurrentPath).EndsWith(

 "aspx", true, System.Globalization.CultureInfo.InvariantCulture))
            "aspx", true, System.Globalization.CultureInfo.InvariantCulture))  {
{
 string strCustomPath;
            string strCustomPath;
 string qString = Request.QueryString.ToString();
            string qString = Request.QueryString.ToString();
 if(qString != string.Empty)
            if(qString != string.Empty)
 qString = "&" + qString;
                qString = "&" + qString;
 strCurrentPath = strCurrentPath.ToLowerInvariant();
            strCurrentPath = strCurrentPath.ToLowerInvariant();
 string appRoot = GetAppRoot(strCurrentPath);
            string appRoot = GetAppRoot(strCurrentPath);
 //string pageName = "";
            //string pageName = "";
 // the URL contains this folder name
            // the URL contains this folder name
 //Response.Write(strCurrentPath);
            //Response.Write(strCurrentPath);

 if(strCurrentPath.IndexOf("catalog/", StringComparison.InvariantCultureIgnoreCase) > -1)
            if(strCurrentPath.IndexOf("catalog/", StringComparison.InvariantCultureIgnoreCase) > -1)  {
{

 appRoot = appRoot.Replace("catalog/", "");
                appRoot = appRoot.Replace("catalog/", "");
 strCustomPath = appRoot + "catalog.aspx?guid=" + System.IO.Path.GetFileNameWithoutExtension(strCurrentPath) + qString;
                strCustomPath = appRoot + "catalog.aspx?guid=" + System.IO.Path.GetFileNameWithoutExtension(strCurrentPath) + qString;

 // rewrite the URL
                // rewrite the URL
 Context.RewritePath(strCustomPath, false);
                Context.RewritePath(strCustomPath, false);
 }
            }

 else if(strCurrentPath.IndexOf("product/", StringComparison.InvariantCultureIgnoreCase) > -1)
            else if(strCurrentPath.IndexOf("product/", StringComparison.InvariantCultureIgnoreCase) > -1)  {
{
 appRoot = appRoot.Replace("product/", "");
                appRoot = appRoot.Replace("product/", "");

 strCustomPath = appRoot + "product.aspx?guid=" + System.IO.Path.GetFileNameWithoutExtension(strCurrentPath);
                strCustomPath = appRoot + "product.aspx?guid=" + System.IO.Path.GetFileNameWithoutExtension(strCurrentPath);
 // rewrite the URL
                // rewrite the URL

 Context.RewritePath(strCustomPath, false);
                Context.RewritePath(strCustomPath, false);
 }
            }
 }
        }
 }
    } 
             
            posted @ 
2008-03-06 09:33 
宿远 
阅读(
2737) 
评论() 
 
收藏 
举报