asp.net-mvc - 从客户端检测到危险的 Request.Form 值 - 为什么?

标签 asp.net-mvc asp.net-mvc-3 httprequest

我阅读了此处与此错误相关的所有其他帖子。也许我在这里遗漏了一些东西,但我不知道是什么。我正在使用 textArea 在其中输入文本(html 文本)。
该文本区域绑定(bind)到我的域类属性

public class SomeClass{
...
[AllowHtml]       
        public string CommentText { get; set; }
...
}

我也尝试添加 [ValidateInput(false)] 属性,但什么也没有。但通过阅读错误文本,我发现请求甚至没有到达 Controller ,它在 Application_BeginRequest() 中被破坏。 这是错误消息:

A potentially dangerous Request.Form value was detected from the client (CommentText="<p>ddd</p>")
Line 23:         protected void Application_BeginRequest(Object sender, EventArgs e)
Line 24:         {
Line 25:             if (HttpContext.Current.Request["RequireUploadifySessionSync"] != null)
Line 26:                 UploadifySessionSync();
Line 27:         }

Source File: D:\Projects\...\Global.asax.cs    Line: 25 

Stack Trace: 


[HttpRequestValidationException (0x80004005): A potentially dangerous Request.Form value was detected from the client (CommentText="<p>ddd</p>").]
   System.Web.HttpRequest.ValidateString(String value, String collectionKey, RequestValidationSource requestCollection) +8755668
   System.Web.HttpRequest.ValidateNameValueCollection(NameValueCollection nvc, RequestValidationSource requestCollection) +122
   System.Web.HttpRequest.get_Form() +114

我知道我可以在网络配置中关闭检查整个应用程序是否正常。但我只在一种情况下需要这个(允许 HTML 输入)。
更奇怪的是,这在几天前就有效了,我在这里没有更改任何内容,只是登录和注销用户。
我在这里做错了什么?
好的,现在我从 global.asax 中删除此代码:

if (HttpContext.Current.Request["RequireUploadifySessionSync"] != null)
                UploadifySessionSync();

现在可以了。但我这里需要这段代码。为什么会产生这个错误?

最佳答案

这个问题已经得到解答。

Previous Question

您需要更改处理请求验证的方式以将其恢复到 2.0

关于asp.net-mvc - 从客户端检测到危险的 Request.Form 值 - 为什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7869214/

相关文章:

c# - 类似但不完全相同的元素的 MVC 部分 View

java - 如何将 session ID 作为请求 header 的一部分传递?

visual-c++ - 将互联网句柄设置为静态成员并在线程外部访问它..需要专家建议

c# - ASP.Net MVC3中如何实现打印

c# - Controller 收不到来自json的数据

asp.net-mvc - Mvc4 捆绑、缩小和 AngularJS 服务

jquery - 如何在MVC3中的Ajax.BeginForm的OnFailure中仅显示错误消息?

asp.net-mvc - MVC3 使用 jquery.validate.unobtrusive.js 和 $ ("#form").submit() hijax 不起作用

c# - NinjectModule 的加载顺序

ios - 如何知道 HTTPRequest 之后所有任务何时完成(Swift)