URL Rewriting
-
hii i have change my url name according to my requirment using global file concept this is my function void Application_BeginRequest(Object sender, EventArgs e) { String strCurrentPath; String strCustomPath; String StrReferrer; if (Request.UrlReferrer != null) StrReferrer = Request.UrlReferrer.PathAndQuery.ToString(); else StrReferrer = ""; // for SubCategory strCurrentPath = Request.Path; strCurrentPath = strCurrentPath.ToLower().Replace("/RedTag/Client/".ToLower(), ""); if (strCurrentPath.StartsWith("subcategory.aspx")) { strCurrentPath = StrReferrer; strCurrentPath = strCurrentPath.ToLower().Replace("/RedTag/Client/".ToLower(), ""); } if (strCurrentPath.StartsWith("c-")) { string id = strCurrentPath.Split('-')[1].ToString(); strCustomPath = "category.aspx?catid=" + id.ToString(); Context.RewritePath(strCustomPath); } if (strCurrentPath.StartsWith("m-")) { string id = strCurrentPath.Split('-')[1].ToString(); strCustomPath = "subcategory.aspx?MFRID=" + id.ToString(); Context.RewritePath(strCustomPath); } if (strCurrentPath.StartsWith("s-")) { string id = strCurrentPath.Split('-')[1].ToString(); strCustomPath = "SubCategory.aspx?catid=" + id.ToString(); HttpContext.Current.RewritePath(strCustomPath); // Context.RewritePath(strCustomPath); } if (strCurrentPath.StartsWith("p-")) { string id = strCurrentPath.Split('-')[1].ToString(); strCustomPath = "ItemPage.aspx?ProductID=" + id.ToString(); Context.RewritePath(strCustomPath); } } now problem is that first time when my subcategory page load that time the url is like Client/s-1001-Data.aspx but when i do paging then my page is ispostback and my url change to SubCategory.aspx?catid=1001 means which is in my Context.RewritePath ..i want the same url name should maintain through out the page...
Jintal Patel