AllowHtml attribute not working

后端 未结 4 747
粉色の甜心
粉色の甜心 2020-12-06 07:38

I have a model with this property:

     [AllowHtml]
     [DisplayName(\"Widget for Table\")]
     [StringLength(1000, ErrorMessage = \"Maximum chars 1000\")]         


        
4条回答
  •  青春惊慌失措
    2020-12-06 08:20

    The way you are using AllowHtml should work. Make sure that you are not accessing the HttpRequest.Form collection anywhere else in your code (controller, filter, etc) as this will trigger ASP.NET Request Validation and the error you are seeing. If you do want access to that variable then you should access it via the following code.

    using System.Web.Helpers;
    
    HttpRequestBase request = ..  // the request object
    request.Unvalidated().Form;
    

提交回复
热议问题