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.

System.Net.Http.HttpClient' does not contain a definition for 'PostAsJsonAsync

A collection with cascade="all-delete-orphan" was no longer referenced by the owning entity instance