2010-08-13 77 views
2

,我发现了‘潜在危险的Request.Form请求值MVC2应用程序是使用我的FCK编辑器,即时通讯在从客户端’异常检测。与CKEDITOR“潜在危险的Request.Form

之前怎么能编码提交形成,或者没有禁用此验证禁用数据Anotations验证

这是我的看法的代码:?

<% 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> 

感谢很多提前

回答

3

[脚本类型= “文本/ JavaScript的” SRC = “/ CKEditor的/ _source /核心/ editor.js内”] [/脚本]

CKEDITOR.config.htmlEncodeOutput = TRUE;

2

如果您正在使用FCK编辑器或CKeditor,则不需要处理“requestValidationMode”。因为它将应用于整个应用程序。 你可以做以下内容:

CKEDITOR.replace('Description', { toolbar: '1', htmlEncodeOutput: true}); 

然后在控制器:

model.Body = System.Net.WebUtility.HtmlDecode(model.Body); 
+0

它的工作完美。 – ujjaval 2015-07-22 06:25:39

相关问题