简体   繁体   中英

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.

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

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

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

将[ValidateInput(false)]放置在控制器的post方法中的ActionResult上方。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM