Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Validate request with Request.Unvalidated() in ASP MVC 3 RC and .NET 4

I have the same problem as below:

ASP.NET MVC 3 ValidateRequest(false) not working with FormCollection

I have tried to add a reference to the System.Web.Helpers dll, and added a using System.Web.Helpers in my controller, but it wont accept Unvalidated() as a method under Request. Im using .NET 4 and MVC 3 RC.

like image 625
Martin at Mennt Avatar asked Dec 08 '10 20:12

Martin at Mennt


People also ask

What is request validation in ASP NET 4?

In ASP.NET 4.0, request validation becomes extensible. This means that you can extend request validation. Also in ASP.NET 4.0, by default request validation is enabled before the BeginRequest phase of an HTTP request.

How do I disable request validation in an MVC application?

To disable request validation in an ASP.NET MVC application, you must change request validation to occur earlier in the sequence of request processing, as explained earlier for ASP.NET Web Forms. In the Web.config file, make the following setting:

What is the value of requestvalidationmode in ASP NET?

The value that you assign to this property is not validated to match a specific version of ASP.NET. Any numeric value smaller than 4.0 (for example, 3.7, 2.9, or 2.0) is interpreted as 2.0. Any number larger than 4.0 is interpreted as 4.0. So defining requestValidationMode="4.5" initially will be interpreted to requestValidationMode="4.0".

What is httprequest validation?

The HttpRequest object internally sets a flag that indicates that request validation should be triggered whenever any HTTP request data is accessed. This guarantees that the request validation is triggered before data such as cookies and URLs are accessed during the request.


1 Answers

The Unvalidated() extension method is defined in the System.Web.WebPages.dll assembly, not System.Web.Helpers.dll (but still in the System.Web.Helpers namespace)

Sorry for the confusion.

like image 156
marcind Avatar answered Oct 12 '22 01:10

marcind