A potentially dangerous Request.Form value was detected from the client
When a user/client of your page/website enters some special characters like "<" or ">" or "#" etc and submits, then you may see this exception "A potentially dangerous Request.Form value was detected from the client". In this article am going to explain how to avoid this error
In our dial programming we may need to provide user with some form and when a user enters the data and submits the form to the server then we need to add those values to database. This works fine when they are no validation errors.
But when a user enters invalid data means when he enters some special characters like <" or ">" or "#" etc and submits the form then we get errors/exceptions.
There are different ways to solve this exception.
If you are using asp.net 4 , then don't forget to add the following code to your web.config file.
<httpRuntime requestValidationMode="2.0" />
Add the above code inside the <system.web> </system.web> tags.
If you are using mvc3, then add the AllowHtml attribute to your model property. Which Initializes a new instance of the AllowHtmlAttribute class. refer: this msdn article
[AllowHtml]
public string yourPropertyName { get; set; }
This means we are allowing the user to add html kind of code in our textboxes.
Hope this may solve your problem..