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

Cause of Error

.NET detected something in entered text which looked like an html statement. ASP.Net By default validates all input controls for potentially unsafe contents that can lead to Cross Site Scripting and SQL Injections. So ASP.Net is not allowing this content so it's blocking by this exception. By default it is recommended to allow this check to happen on each postback.

Solution
So you can avoid this exception by adding below line
<%@ Page Language="C#" AutoEventWireup="true" ValidateRequest = "false"

it will disable the request validation for current page. if you want to disable for whole application then you can put in web.config as below in system.Web section.
<pages validateRequest ="false" />


For .Net 4.0 or higher versions write below code under System.Web section.

<httpRuntime requestValidationMode = "2.0" />


Comments

Popular posts from this blog

Swagger for Azure functions: Undocumented TypeError: Failed to execute 'fetch' on 'Window': Request with GET/HEAD method cannot have body. Fixed.

Fixed: The required column was not present in the results of a 'FromSql' operation in asp.net core EF core

Severity Code Description Project File Line Suppression State Error Unable to resolve dependencies. 'Xamarin.Android.Support.Design 24.2.1' is not compatible with 'Xamarin.Forms 2.3.3.180 constraint: Xamarin.Android.Support.Design (= 23.3.0)'. 0