【问题标题】:sitfinity MVC wideget not accepting html tag through kendo text editorsitefinity MVC 小部件不接受通过剑道文本编辑器的 html 标记
【发布时间】:2015-05-29 10:27:53
【问题描述】:

我在 sitefinity 中使用 MVC 小部件并尝试使用文本编辑器,以便内容管理器能够使用 kendo 添加 HTML 编辑器,因此他们可以使文本加粗并添加要点,每当我尝试保存数据时,我都会收到错误消息以下是有关如何解决此问题的任何想法。

从 客户 (paragraph_text="asdsadasc fasdf

控制器:

[ValidateInput(false)]
[HttpPost]
public ActionResult CreateParagraph(contentModel model)
{
   ...
}

型号:

 [AllowHtml] 
 public string paragraph_text { get; set; }

【问题讨论】:

    标签: asp.net-mvc sitefinity


    【解决方案1】:

    当时的设计者 Js 对字符串进行编码,然后在其呈现在视图中之前决定。您将在应用更改功能中对此进行编码。

    【讨论】:

      【解决方案2】:

      我意识到这是一个较老的问题,但我最近遇到了这个问题。为了解决这个问题,我们必须创建一个自定义请求验证器类,如本文所述:https://knowledgebase.progress.com/articles/Article/a-potentially-dangerous-request-form-error

      public class CustomRequestValidatorCustom : CustomRequestValidator
      {
          internal static readonly string[] _nonValidatedFilePaths =
          {
              "/<controller>/<action>/",
          };
      
          protected override bool IsValidRequestString(HttpContext context, string value, System.Web.Util.RequestValidationSource requestValidationSource, string collectionKey, out int validationFailureIndex)
          {
              var isValid = base.IsValidRequestString(context, value, requestValidationSource, collectionKey, out validationFailureIndex);
      
              if (!isValid)
              {
                  isValid |= context.Request.FilePath != null && context.Request.FilePath.In(_nonValidatedFilePaths);
              }
      
              return isValid;
          }        
      }
      

      【讨论】:

      • 令人恼火的是 SF 无法识别 [ValidateInput(false)] / [AllowHtml] 数据注释。
      猜你喜欢
      • 1970-01-01
      • 2019-11-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-07-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多