Jakub Šturc
Jakub Šturc

Reputation: 35767

How to disable request validation in ASP.NET MVC running at IIS6?

I have ASP.NET MVC application with action which should process posted XML data. At Cassini is working everything fine but when I deploy application to IIS6 I am getting following error.

A potentially dangerous Request.Form value was detected from the client (xml="<?xml version="1.0" ...").

I tried decorate controller with ValidateInput(false) attribute and I also add following method to controller.

protected override void Initialize(RequestContext requestContext)
{
  ValidateRequest = false;
  base.Initialize(requestContext);
}

Nothing help.

Do you have any other idea how can I get rid off this annoying request validation?

Edit: Sorry. I was totally my error as usual. After I setup wildcard mapping everything is working fine.

Upvotes: 0

Views: 833

Answers (3)

Kevin LaBranche
Kevin LaBranche

Reputation: 21078

Put [ValidateInput(false)] above your ActionResult in your controller's post methods....

Upvotes: 1

Kieron
Kieron

Reputation: 27107

As Richard said, you should place it on the action method accepting the input:

[HttpPost]
[ValidateInput (false)]
public ActionResult DoTheThing (StuffBeingPostedBack stuff)
{
    // ...
}

Upvotes: 2

RichardOD
RichardOD

Reputation: 29157

Is it (ValidateInput) on a POST method? It only works with POST.

Upvotes: 2

Related Questions