What is the meaning of A potentially dangerous Request.Form value was detected from the client error message

后端 未结 4 462
闹比i
闹比i 2021-01-23 17:41

I was trying to send an email via my web project using Free text box control.It is an text editor . but I\'ve got this error.

A potentially dangerous Request.For

相关标签:
4条回答
  • 2021-01-23 18:01

    FreeTexBox control and "A potentially dangerous Request.Form value was detected from the client"

    You can try another decision

     if(!this.Page.ClientScript.IsOnSubmitStatementRegistered("Replace"))
    {
     string script = @"if (Page_IsValid){FTB_API['" + txtBox.ClientID + @"'].initialized=false;   FTB_API['"  + txtBox.ClientID + @"'].htmlEditor.value=FTB_FreeTextBox.prototype.HtmlEncode( FTB_API['" + txtBox.ClientID + @"'].htmlEditor.value);}";
     this.Page.ClientScript.RegisterOnSubmitStatement(this.Page.GetType(), "Replace", script);
    }
    

    and don't forget to replace symbols when you send string from server to the client application

    if(!String.IsNullOrEmpty(yourstring)) txtBox.Text= yourstring.Replace("&gt;", ">").Replace("&lt;", "<").Replace("&amp;", "&").Replace("&quot;", ('"').ToString()).Replace("&#146;", "'");
    
    0 讨论(0)
  • 2021-01-23 18:10

    Please see the answer on this question:

    ValidateRequest="false" doesn't work in Asp.Net 4

    This is a change in .net 4.0.

    0 讨论(0)
  • 2021-01-23 18:14

    If you are running .NET 4.0, add this in your web.config (under system.web)

    <httpRuntime requestValidationMode="2.0" />
    
    0 讨论(0)
  • 2021-01-23 18:23

    I've had this before.

    You need to also add to your web.config file.

    If you put your page into debug mode and read the text with the error message it tells you what to add and where to add it. I cant remember 100% why the error occurs, I think it's something to do with page content on postback and the browser thinking there is harmfull code in there.

    See also: A potentially dangerous Request.Form value was detected from the client

    and

    http://www.codeproject.com/Tips/297679/A-potentially-dangerous-Request-Form-value-was-det

    for a more complete explanation and solution.

    0 讨论(0)
提交回复
热议问题