从客户端检测到潜在危险的Request.Form值

Dof*_*ofs 11 asp.net-mvc ckeditor ckfinder

我在我的MVC.NET站点上使用CKEditor/CKFinder作为wysiwyg编辑器.

我已设置[ValidateInput(false)]并在本地调试时有效,但在发布网站时收到以下错误:

A potentially dangerous Request.Form value was detected from the client (message="<p>
<em>Testing</e...").
Run Code Online (Sandbox Code Playgroud)

任何人都可以解释为什么发布的网站不同于本地网站,特别是当我设置[ValidateInput(false)]

*更新:*我使用的是.Net 3.5,所以不应该 [ValidateInput(false)]开箱即用?

Cat*_*h22 25

您是否尝试过设置htmlEncodeOutput属性?

CKEDITOR.replace('editor1', {
    htmlEncodeOutput: true });
Run Code Online (Sandbox Code Playgroud)

这应该对输出进行编码,您应该可以避免设置requestValidationMode.

它的文档在这里:ckEditor文档

  • +1这比我认为禁用验证更好. (7认同)

sti*_*net 7

将其添加到您的web.config:

<httpRuntime requestValidationMode="2.0" />
Run Code Online (Sandbox Code Playgroud)

  • 答案是让主机将App池更改为.Net 3.5,但是如果我运行.net 4.0,这个答案会有所帮助我将其标记为答案. (2认同)