When I run my crawler once it works on any page. Run it again on another page or the same page and I get this error

Server Error in '/WebApplication5' Application.
--------------------------------------------------------------------------------

A potentially dangerous Request.Form value was detected from the client (txtBody="...e customer’s experience,..."). 
Description: Request Validation has detected a potentially dangerous client input value, and processing of the request has been aborted. This value may indicate an attempt to compromise the security of your application, such as a cross-site scripting attack. You can disable request validation by setting validateRequest=false in the Page directive or in the configuration section. However, it is strongly recommended that your application explicitly check all inputs in this case. 

Exception Details: System.Web.HttpRequestValidationException: A potentially dangerous Request.Form value was detected from the client (txtBody="...e customer’s experience,...").

Source Error: 

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.  

Stack Trace: 


[HttpRequestValidationException (0x80004005): A potentially dangerous Request.Form value was detected from the client (txtBody="...e customer’s experience,...").]
   System.Web.HttpRequest.ValidateString(String s, String valueName, String collectionName)
   System.Web.HttpRequest.ValidateNameValueCollection(NameValueCollection nvc, String collectionName)
   System.Web.HttpRequest.get_Form() +113
   System.Web.UI.Page.GetCollectionBasedOnMethod()
   System.Web.UI.Page.DeterminePostBackMode()
   System.Web.UI.Page.ProcessRequestMain()
   System.Web.UI.Page.ProcessRequest()
   System.Web.UI.Page.ProcessRequest(HttpContext context)
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication+IExecutionStep.Execute()
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

 


--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:1.1.4322.2032; ASP.NET Version:1.1.4322.2032

At this point it's simply reading a string. html/text that has already been imported.

I know because the error always occurs in the same spot. After the AspTear Component has been closed.

I do have some Google Ads on my page that might cause this error, I'm guessing.

Here is the Sub where the error is occuring if it's helpful:

Private Sub Extract_Body()
        Dim strBody
        Dim lenBody
        Dim chkBody
        Dim arrBody
        Dim lenStr
        Dim i
        On Error Resume Next

        strBody = Left(strRetval, InStr(strRetval, LCase("</body")) - 1)
        chkBody = InStr(strBody, LCase("<body"))
        lenBody = Len(strBody)
        strBody = Right(strBody, lenBody - chkBody + 1)

        arrBody = Split(strBody, ">")
        lenBody = UBound(arrBody)
        For i = 0 To lenBody
            strBody = Left(arrBody(i), InStr(arrBody(i), "<"))
            strBody = Replace(strBody, "<", "")
            txtBody.Text = txtBody.Text & strBody & vbCrLf
        Next i


    End Sub

Maybe I will try discarding the Google Script
( Probably a good idea anyway )

Well I studied the error and found a WorkAround.

disable request validation by setting validateRequest=false in the Page directive or in the configuration section. However, it is strongly recommended that your application explicitly check all inputs in this case.
<%@ Page validateRequest=false .....

Not real happy with the idea, but it looks like the only option for now.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.