GibbsUSA.net Blogs
Wednesday, September 08, 2010
Logon Back to Blog Blogs Home GibbsUSA.net Home
Leave your comments...
protected void Application_BeginRequest(Object sender, EventArgs e) { // code to make blogs search engine friendly HttpContext incoming = HttpContext.Current; string oldpath = incoming.Request.Path.ToLower(); if(oldpath.ToLower().IndexOf("_page-")>0) { string pageRedirect = oldpath.Substring(oldpath.LastIndexOf("/")+1); pageRedirect = pageRedirect.Substring(0,pageRedirect.ToLower().IndexOf("_page")); // extract the items string qsItemsTemp = oldpath.Substring(oldpath.ToLower().IndexOf("_page-")+6); qsItemsTemp = qsItemsTemp.Substring(0,qsItemsTemp.ToLower().IndexOf(".aspx")); string[] qsItems = qsItemsTemp.Split('-'); string theQString = ""; for (int i=0;i<=qsItems.GetUpperBound(0);i++) { if (theQString.Length>0) { theQString += "&"; } theQString += qsItems[i].ToString() + "=" + qsItems[i+1].ToString(); i++; } incoming.RewritePath (pageRedirect + ".aspx?" + theQString); } else { // Display path if it doesn’t contain _pageX.aspx incoming.RewritePath(oldpath ); } }
CLR v2.0.50727.3053
Please see the site Terms And Conditions and the site Privacy Statement.This entire web site (and the software contents therein) is Copyright © Chris Gibbs 2000-2010. Any reproduction or copying is expressly forbidden without the prior consent of Chris Gibbs. For more information, please contact the site WebMaster (WebMaster@GibbsUSA.net).