Asp.net mvc 如何在kendoui编辑器中避免重复编码?

Asp.net mvc 如何在kendoui编辑器中避免重复编码?,asp.net-mvc,kendo-ui,kendo-asp.net-mvc,Asp.net Mvc,Kendo Ui,Kendo Asp.net Mvc,我希望编辑器可以编码,因为我想将编辑器文本发布到控制器,但我发现当我刷新页面(单击F5)时,编辑器会再次编码文本。我的Model.Body也包含html标记:例如,第一次进入页面是确定的,并显示“我的模型Body在这里”,我刷新页面,它显示如下html标记,但我只想编码一次,我也不使用缓存,但它不工作。第三次刷新页面,它再次编码,并显示tabletbody… 型号: //after search,my Model.Body is here <table> <tbody>

我希望编辑器可以编码,因为我想将编辑器文本发布到控制器,但我发现当我刷新页面(单击F5)时,编辑器会再次编码文本。我的
Model.Body
也包含html标记:例如,第一次进入页面是确定的,并显示“我的模型Body在这里”,我刷新页面,它显示如下html标记,但我只想编码一次,我也不使用缓存,但它不工作。第三次刷新页面,它再次编码,并显示
tabletbody…

型号

//after search,my Model.Body is here
 <table>
 <tbody>
 <tr><td align="center" style="font-weight:bold;">
 <span style="background-color:#ccff33;">My Model Body Is Here</span>
 </td></tr> 
 </tbody>
 </table>
  @(Html.Kendo().Editor()
  .Name("Body")
  .Tools(tools => tools.Clear()
  .Bold().Italic().Underline().Strikethrough()
  .JustifyLeft().JustifyCenter().JustifyRight().JustifyFull()
  .InsertUnorderedList().InsertOrderedList()
  .Outdent().Indent()
  .CreateLink().Unlink()
  .InsertImage()
  .SubScript()
  .SuperScript()
  .ViewHtml()
  .FontName()
  .FontSize()
   .FontColor().BackColor()
   )
   .HtmlAttributes(new { style = "width:90%;height:500px" })
   .Value(Model.Body))
 [OutputCache(Duration = 0)]
 public ActionResult Index(int id=0)
 {
 return View(ModelRepository.GetModelById(id));
 }
控制器

//after search,my Model.Body is here
 <table>
 <tbody>
 <tr><td align="center" style="font-weight:bold;">
 <span style="background-color:#ccff33;">My Model Body Is Here</span>
 </td></tr> 
 </tbody>
 </table>
  @(Html.Kendo().Editor()
  .Name("Body")
  .Tools(tools => tools.Clear()
  .Bold().Italic().Underline().Strikethrough()
  .JustifyLeft().JustifyCenter().JustifyRight().JustifyFull()
  .InsertUnorderedList().InsertOrderedList()
  .Outdent().Indent()
  .CreateLink().Unlink()
  .InsertImage()
  .SubScript()
  .SuperScript()
  .ViewHtml()
  .FontName()
  .FontSize()
   .FontColor().BackColor()
   )
   .HtmlAttributes(new { style = "width:90%;height:500px" })
   .Value(Model.Body))
 [OutputCache(Duration = 0)]
 public ActionResult Index(int id=0)
 {
 return View(ModelRepository.GetModelById(id));
 }

尝试在编辑器中设置
.Encode(false)
。当显示内容时,您可能必须执行
@Html.Raw(Model.content)

这是由从浏览器缓存中获取页面时编辑器的默认编码引起的。为了解决这个问题,请在视图中设置Encoded(false),并通过设置[allowtml]属性指示该字段将在模型中包含HTML。另一方面,您可以禁用bfcache