带有 Ckeditor 的 MVC2 应用程序“潜在危险的 Request.Form”
当我使用 FCK 编辑器时,我收到“从客户端检测到潜在危险的 Request.Form 请求值”异常。
如何在提交表单之前进行编码,或者在不禁用数据注释验证的情况下禁用此验证?
这是我的观点的代码:
<% using (Html.BeginForm()) {%>
<%: Html.ValidationSummary("Please complete in a right way the fields below.") %>
<fieldset>
<legend>Fields</legend>
<div class="editor-field">
<%: Html.LabelFor(e => e.Name)%>
<%: Html.TextBoxFor(e => e.Name)%>
<%: Html.ValidationMessageFor(e => e.Name)%>
</div>
<div class="editor-field">
<%: Html.LabelFor(e => e.Teaser) %>
<%: Html.TextAreaFor(e => e.Teaser)%>
<%: Html.ValidationMessageFor(e => e.Teaser)%>
</div>
<div class="editor-field">
<%: Html.LabelFor(e => e.Description) %>
<%: Html.TextAreaFor(e => e.Description)%>
<%: Html.ValidationMessageFor(e => e.Description)%>
</div>
<p>
<input type="submit" />
</p>
</fieldset>
<% } %>
<script type="text/javascript">
//<![CDATA[
// This call can be placed at any point after the
// <textarea>, or inside a <head><script> in a
// window.onload event handler.
// Replace the <textarea id="xxxxxx"> with an CKEditor
// instance, using default configurations.
CKEDITOR.replace("Description");
//]]>
</script>
提前非常感谢。
I'm getting the "Potentially dangerous Request.Form request value was detected from the client" exception when im using my FCK editor.
How could encode before submit the form, or disable this validation without disable the Data Anotations validation?
This is the code of my view:
<% using (Html.BeginForm()) {%>
<%: Html.ValidationSummary("Please complete in a right way the fields below.") %>
<fieldset>
<legend>Fields</legend>
<div class="editor-field">
<%: Html.LabelFor(e => e.Name)%>
<%: Html.TextBoxFor(e => e.Name)%>
<%: Html.ValidationMessageFor(e => e.Name)%>
</div>
<div class="editor-field">
<%: Html.LabelFor(e => e.Teaser) %>
<%: Html.TextAreaFor(e => e.Teaser)%>
<%: Html.ValidationMessageFor(e => e.Teaser)%>
</div>
<div class="editor-field">
<%: Html.LabelFor(e => e.Description) %>
<%: Html.TextAreaFor(e => e.Description)%>
<%: Html.ValidationMessageFor(e => e.Description)%>
</div>
<p>
<input type="submit" />
</p>
</fieldset>
<% } %>
<script type="text/javascript">
//<![CDATA[
// This call can be placed at any point after the
// <textarea>, or inside a <head><script> in a
// window.onload event handler.
// Replace the <textarea id="xxxxxx"> with an CKEditor
// instance, using default configurations.
CKEDITOR.replace("Description");
//]]>
</script>
Thanks a lot in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
[脚本类型=“text/javascript”src=“/ckeditor/_source/core/editor.js”][/script]
CKEDITOR.config.htmlEncodeOutput = true;
[script type="text/javascript" src="/ckeditor/_source/core/editor.js"][/script]
CKEDITOR.config.htmlEncodeOutput = true;
如果您使用 FCK 编辑器或 CKeditor,则不需要处理“requestValidationMode”。因为它将应用于整个应用程序。
您可以执行以下操作:
然后在控制器中:
If you are working with the FCK editor or CKeditor you do not need to deal with the "requestValidationMode". As it will be applied on the entire application.
You can just do the followings:
Then in the controller:
config.htmlEncodeOutput
但使用CKEditor 的 .Net 包装器。
config.htmlEncodeOutput
But it might be easier to use a .Net wrapper for CKEditor.
检查:请求验证 - ASP.NET MVC 2
<httpRuntime requestValidationMode="2.0" />
Check: Request Validation - ASP.NET MVC 2