0

When I did goggling for this error than I got lots of solution and every where I got same answer But I could not solve in my case.

Error

A potentially dangerous Request.Form value was detected from the client (ctl00$ContentPlaceHolder1$tbEditor="<span>
<span><sp...").

Explanation

As I could know from another answers if i want to solve this error than i will have to set <httpRuntime requestValidationMode="2.0" /> in my web.config in <system.web> tag as i have done. And another setting in page directive ValidateRequest="false"that i have done and it working fine also for this page.

Problem

But after that when i want to move from this page to any other .aspx page then i am getting as above error.

Here my web.config

    <system.web>
        <authentication mode="Forms" />
        <compilation debug="true" targetFramework="4.0">
            <assemblies>
                <add assembly="System.Data.Services.Client, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
                <add assembly="System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
                <add assembly="System.Web.Extensions.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
                <add assembly="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
            </assemblies>
        </compilation>
        <httpRuntime requestValidationMode="2.0" />
    </system.web>

My page directive where I want to fix this issue.

<%@ Page Title="" Language="C#" MasterPageFile="~/AdminMaster.master" AutoEventWireup="true" CodeFile="EmailSetting.aspx.cs" Inherits="EmailSetting" ValidateRequest="false" %>
4
  • How are you moving from page to page? Blindly turning off validation throughout the site probably isn't a good idea, it's there for a reason. The error indicates that you're posting HTML code in a control called tbEditor. Are you doing that? Do you need to?
    – David
    Jun 12, 2014 at 10:20
  • Yes tbEditor is passing a value from one page to another page i am don't know how it is passing. And i am using simple master page link to move from one page to another. Jun 12, 2014 at 10:32
  • The point is that the value being submitted on the form is an HTML string. That's generally not a good idea for a number of reasons. Why is the value an HTML string in this case? Chances are that you can fix this by passing some other form of data instead of HTML code.
    – David
    Jun 12, 2014 at 10:34
  • here i am using bootstrap editor in which i allow user to format his/her document for email.And this editor's text i send as an email using of code Jun 12, 2014 at 10:37

1 Answer 1

0

Cause

ASP.Net By default validates all input controls for potentially unsafe contents that can lead to Cross Site Scripting and SQL Injections. Thus it disallows such content by throwing the above Exception. By default it is recommended to allow this check to happen on each postback.

Option 1:

In that case you can avoid this exception by setting the ValidateRequest tag in the @Page Directive to false.

<%@ Page Language="C#" AutoEventWireup="true" ValidateRequest = "false" ..>

This will disable the validation of requests for the page you have set the ValidateRequest flag to false. If you want to disable this check throughout your Web Application you’ll need to set it false in your web.config section

Option 2:

<pages validateRequest ="false" />

Option 3:

For .Net 4.0 or higher frameworks you will need to also add the following line in the section to make the above work.

<httpRuntime requestValidationMode = "2.0" />

Try this Solution:

<system.web>
    <compilation debug="true" targetFramework="4.0" />
    <httpRuntime requestValidationMode="2.0" />
</system.web>

Read More on MSDN

2
  • I can not remove assemblies it is being used.When i am removing then i am getting error. Jun 12, 2014 at 10:27
  • your all answers options are true but in my case i want to disable the validation of requests for only one page and as you have suggested that i have tried. But in my case i am not getting error on this page.I am getting error when i am redirecting from this page to any other .aspx page as i have mentioned above. Jun 12, 2014 at 10:41

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.