如何访问未经验证的项目Request.Form集合在MVC 3 [英] How can I access unvalidated items in the Request.Form collection in MVC 3

查看:90
本文介绍了如何访问未经验证的项目Request.Form集合在MVC 3的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用ASP.NET MVC 3 .NET 4.0。我有其中的一个属性需要HTML内容被允许的典范。我已经把我的模型属性,它允许对HTML该属性的 AllowHtml 属性。这一工程本身。

I am using ASP.NET MVC 3 with .NET 4.0. I have a model on which one of the properties requires that HTML content be allowed. I have placed the AllowHtml attribute on my model property which allows HTML on that property. That works by itself.

我也用在我的网站的其他部分 Uploadify Flash上​​传。由于问题闪光灯和访问,我使用一些code类似于在<一的code href=\"http://$c$c.google.com/p/swfupload/source/browse/swfupload/trunk/samples/samples/asp.net/Global.cs.asax\"相对=nofollow> SWFUpload的例子来让我的文件上传访问会话数据。基本上我直接访问的Request.Form 集合中的的Application_BeginRequest 处理程序。

I am also using the Uploadify flash uploader on other parts of my website. Due to problems with flash and sessions, I'm using some code similar to the code in a swfupload example to allow my file upload access to session data. Basically I'm accessing the Request.Form collection directly in the Application_BeginRequest handler.

我遇到的问题是,当允许HTML的形式提出,我收到了的Htt prequestValidationException 时,在code中的的Application_BeginRequest 处理程序访问 Request.Forms [关键] 集合。

The problem I'm running into is that when the form that allows HTML is posed I get a HttpRequestValidationException when the code in the Application_BeginRequest handler access the Request.Forms[key] collection.

就像我在开始时说,我已经试过了 AllowHtml 属性。我也试着使用 ValidateInput(假)属性的动作和控制器级别禁用验证,但我相信我在为那些请求生命周期为时尚早应用。反正是有访问包含有潜在危险的数据的Request.Form 集合而不禁用请求验证整个网站?

Like I said in the beginning, I've tried the AllowHtml attribute. I've also tried disabling validation at the action and controller level using the ValidateInput(false) attribute, but I believe I'm too early in the request life cycle for those to apply. Is there anyway to access the Request.Form collection containing "potentially dangerous" data without disabling request validation for the entire site?

推荐答案

您问这样的:<一href=\"http://stackoverflow.com/questions/4392186/validate-request-with-request-unvalidated-in-asp-mvc-3-rc-and-net-4\">Validate与Request.Unvalidated()中的ASP MVC 3 RC和.NET 4 请求?

Request.Unvalidated().Params[""]

这篇关于如何访问未经验证的项目Request.Form集合在MVC 3的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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