我阅读了此处与此错误相关的所有其他帖子。也许我在这里遗漏了一些东西,但我不知道是什么。我正在使用 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();
现在可以了。但我这里需要这段代码。为什么会产生这个错误?
最佳答案
关于asp.net-mvc - 从客户端检测到危险的 Request.Form 值 - 为什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7869214/