ASP.NET MVC 3 ValidateRequest(假)不是的FormCollection工作 [英] ASP.NET MVC 3 ValidateRequest(false) not working with FormCollection

查看:111
本文介绍了ASP.NET MVC 3 ValidateRequest(假)不是的FormCollection工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

仅供参考我使用.NET 4.0 / MVC 3。

FYI I am using .NET 4.0 / MVC 3.

在我的控制器,下面是我的code:

In my controller, the following is my code:

[HttpPost]
[ValidateInput(false)]
public ViewResult Edit(ContentTemplateView contentTemplateView, FormCollection collection)

一切,当我不输入HTML工作得很好,所以我知道正确的控制器被解雇。另外,我有以下正确设置在我的web.config文件:

Everything works fine when I don't enter HTML, so I know the proper controller is being fired. Also, I have following set properly in my web.config files:

<httpRuntime requestValidationMode="2.0"/>

我只当我包括的FormCollection(这是需要这种特殊控制器)搞定这个问题。那么究竟我做错了?

I only get this problem when I include the FormCollection (which is needed for this particular Controller). So what exactly am I doing wrong?

[我做了什么,提出了以下问题,只要不存在的FormCollection他们的工作。他们没有提供与包括的FormCollection的解决方案]

[I have done what was proposed on the following questions, and they work as long as there is no FormCollection. None of them offer a solution with an included FormCollection]

  • Why is ValidateInput(False) not working?
  • Asp.Net MVC Input Validation still firing after being disabled
  • ValidateInput Attribute Doesn't Seem To Work in ASP.NET MVC

推荐答案

我想我已经解决了我自己的谜语,与本论坛的帮助:<一href=\"http://forums.asp.net/p/1621677/4163625.aspx\">http://forums.asp.net/p/1621677/4163625.aspx

I think I've solved my own riddle, with the help of this forum: http://forums.asp.net/p/1621677/4163625.aspx

我只是修改了我的控制,使其不接受控制器,而是从Request [与System.Web.Helpers的帮助]抢到未经验证的形式征收。

I just modified my Controller so that it didn't accept the Controller, and instead grabbed the unvalidated form collection from the Request [with the help of System.Web.Helpers].

using System.Web.Helpers;

[HttpPost]
[ValidateInput(false)]
public ViewResult Edit(ContentTemplateView contentTemplateView)
{
    FormCollection collection = new FormCollection(Request.Unvalidated.Form);

这篇关于ASP.NET MVC 3 ValidateRequest(假)不是的FormCollection工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆