“潜在危险的Request.Form...” MVC 2.0 中的错误
web.config(system.web)中的ValidateInputAttribute,ValidateInput,httpRuntime requestValidationMode =“2.0”都没有修复,在我看来“ValidateRequest =”false“”也是如此。我正在使用 MVC 2、Visual Studio 2010、.NET 4.0,但仍然收到以下错误:
A potentially dangerous Request.Form value was detected from the client (Body="<p>test</p>").
This is with CKEditor。我已经使用 Ckeditor 查看了 MVC2 应用程序“潜在危险的 Request.Form,但这可能已经过时了。
请帮忙!!谢谢 更新
:
原来你必须调整根 web.config,而不是你的 Views 文件夹中的 web.config,谢谢大家!
ValidateInputAttribute, ValidateInput, httpRuntime requestValidationMode="2.0" in web.config (system.web) all do not fix, also the "ValidateRequest="false"" in my view. I'm using MVC 2, Visual Studio 2010, .NET 4.0, and I'm still getting the following error:
A potentially dangerous Request.Form value was detected from the client (Body="<p>test</p>").
This is with CKEditor. I've already looked at MVC2 application with Ckeditor "potentially dangerous Request.Form, but that might be old.
Please help!! Thanks.
UPDATE:
Soooo.... turns out you have to tweak the root web.config, and NOT the web.config that's in your Views folder. sweet mercy. thanks everyone!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我发现您需要转到控制器上的操作,该操作正在从 CKEditor 增强表单接收发布数据,并在该操作上添加如下属性:
I have found that you need to go to the Action on the controller which is recieving the post data from the CKEditor enhanced form and on that action add the attribute like this:
到 web.config 的 System.Web 部分添加此 -
并使用
On the action 方法
To the System.Web section of your web.config add this -
And use
On the action Method
作为先前建议的替代方案,我发现对传回控制器的内容进行 HTML 编码解决了该问题。
您可以通过将
config.htmlEncodeOutput = true;
添加到 CKEditor 的配置文件 (~/ckeditor/config.js) 来完成此操作。相关文档可以在以下位置找到: https://docs -old.ckeditor.com/ckeditor_api/symbols/CKEDITOR.config.html#.htmlEncodeOutput。
As an alternative to the previous suggestions, I found HTML encoding what was passed back to the controller resolved the issue.
You can do this by adding
config.htmlEncodeOutput = true;
to CKEditor's config file (~/ckeditor/config.js).The relevant documentation can be found at: https://docs-old.ckeditor.com/ckeditor_api/symbols/CKEDITOR.config.html#.htmlEncodeOutput.
您可能想在您的 aspx.cs 站点中覆盖 OnError 事件(在此错误上触发)并处理此错误
更新:
我还没有测试过,但将此方法留空(只需删除:base .OnError(e); 在复制粘贴到您的代码之前)可能会解决您的问题。
You might want to override OnError event (which is fired on this error) in your aspx.cs site and there handle this error
Update:
I havent tested that, but leaving this method blank (just delete: base.OnError(e); before copy-pasting into your code) might solve your problem.