C# 4.0 AllowHtml属性不适用于生产
我有一个需要捕获html的模型。我已经将[AllowHtml]属性添加到model属性中,调试时它可以在本地服务器上正常工作 然而,一旦部署到生产环境中,它在生产服务器上执行时可以正常工作(即,我远程访问服务器并在那个里浏览),但在从任何其他机器执行时会出现通常的“潜在危险的废话”消息 所以在我看来,这似乎与验证所涉及的位置有关,或者我完全错过了这条船 只是确认一下,我没有对web.config进行“特殊”更改 请有人解释一下我为什么会有这个问题 模型C# 4.0 AllowHtml属性不适用于生产,c#-4.0,asp.net-mvc-4,attributes,C# 4.0,Asp.net Mvc 4,Attributes,我有一个需要捕获html的模型。我已经将[AllowHtml]属性添加到model属性中,调试时它可以在本地服务器上正常工作 然而,一旦部署到生产环境中,它在生产服务器上执行时可以正常工作(即,我远程访问服务器并在那个里浏览),但在从任何其他机器执行时会出现通常的“潜在危险的废话”消息 所以在我看来,这似乎与验证所涉及的位置有关,或者我完全错过了这条船 只是确认一下,我没有对web.config进行“特殊”更改 请有人解释一下我为什么会有这个问题 模型 [AllowHtml] [Display(
[AllowHtml]
[Display(Name = "Overview")]
public string Overview { get; set; }
控制器
//
// POST: /Product/
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult EditFeature(BackOffice.Models.ProductFeature model)
{
if (ModelState.IsValid)
{
//insert the new product
}
//invalid model, return with errors
return View(model);
}
看法
@model BackOffice.Models.ProductFeature
@使用(Html.BeginForm(“AddFeature”、“Product”、null、FormMethod.Post、new{role=“form”、@class=“form horizontal”}))
{
@Html.AntiForgeryToken()
@Html.ValidationSummary(true)
@Html.Hidden(“ProductID”,@Model.ProductID)
&时代;
添加一个特性
标题
@TextBoxFor(m=>m.Title,新的{@class=“form control”})
@Html.ValidationMessageFor(m=>m.Title)
概述
@TextAreaFor(m=>m.Description,10,40,新的{@class=“ckeditor”,id=“overview”})
接近
添加
}
此处的方法名称不匹配。你有
@using (Html.BeginForm("AddFeature", "Product", null, FormMethod.Post, new { role = "form", @class = "form-horizontal" }))
{
}
但是您的操作方法被调用
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult EditFeature(BackOffice.Models.ProductFeature model)
{
}
AddFeature操作方法在哪里?编辑和添加中使用的模型是相同的?@Romias是的,它们是相同的,从不同的机器调用时,插入/更新都失败。
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult EditFeature(BackOffice.Models.ProductFeature model)
{
}