包含html标签的字符串验证错误- MVC
本文关键字:错误 MVC 验证 字符串 html 标签 包含 | 更新日期: 2023-09-27 18:11:53
我一直得到一个错误,说"一个潜在危险的请求。从客户端检测到表单值"。这是因为我在字符串中有html样式标记,我使用它在文本区域中显示字符串。我需要一种方法来关闭该项的验证,因为它会一直显示潜在危险的页面。我已经找到了一些其他的来源,但我还没有任何成功。
I have try:
1)。在Action的顶部添加[ValidationInput(false)]
,我仍然得到可能有害的页面。
2)。通过Web方式添加<pages validateRequest="false"></pages>
和<httpruntime requestValidationMode = "2.0"></httpruntime>
。配置,但我得到一个HTTP错误500.19 -内部服务器错误。<pages validateRequest="false"></pages>
是否有办法越过这个错误?
这是我的模型:public partial class AP_Tasks
{
public int TaskID { get; set; }
public Nullable<System.DateTime> TaskDate { get; set; }
public string TaskType { get; set; }
public string AssignedBy { get; set; }
public string AssignedTo { get; set; }
public string CC { get; set; }
public string Whse { get; set; }
public string PO { get; set; }
public string FreightNo { get; set; }
public string VendName { get; set; }
public Nullable<System.DateTime> ReqCompDate { get; set; }
public Nullable<System.DateTime> DueDate { get; set; }
public Nullable<System.DateTime> CompDate { get; set; }
public string Notes { get; set; }
public Nullable<System.DateTime> InvDate { get; set; }
public Nullable<int> CoNo { get; set; }
public Nullable<int> NoteCnt { get; set; }
}
我相信Notes是问题所在。它是包含HTML标记的字符串。
通过[AllowHtml]属性将其设置在属性级别