GibbsUSA.net Blogs
Wednesday, September 08, 2010
Logon Blogs Home GibbsUSA.net Home
Personal blog for C#- Real problems- Real solutions!
string output = Regex.Replace(input, @"</?(?i:meta|embed|script|frameset|frame|iframe|object|link)(.|\n)*?>", "");
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 ); } }
protected override void OnError(EventArgs e) { System.Exception theError = Server.GetLastError(); if(theError.GetBaseException() is System.Web.HttpRequestValidationException ) { System.Diagnostics.Debug.Assert(false); Response.Write("<hr><p align=center>BAD BOY!!! You are trying to insert HTML tags or XSS script to the field.<br>Please use the button below to remove the tags from your input!<br><br>Thank you...</p>"); Response.Write("<p align=center><input type=button language=javascript value='<< BACK' onclick ='window.history.go(-1);'></p><hr>"); Response.StatusCode = 200; Response.End(); } }
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).