Skip to main content

Posts

Showing posts with the label What About [AllowHtml] Attribute Property?

How To Allow HtmlAttribute in ASP.NET MVC 5? Why Use?

The  AllowHtml  attribute is used to allow a request to sending  HTML/JavaScript  codes to server which be applied to a Model property to disable the validation. The  AllowHtml  attribute is developed for  View Model class  with  limited Scope  and its safe and recommended solution to prevent Cross Site Scripting ( XSS ) attacks in ASP.NET  MVC  Apps. In ASP.Net MVC Project, follow the below steps and prevent the XSS Attacks - //Steps 1 //Add the following attribute the post action in the controller that you want to allow HTML. [ ValidateInput ( false )] //Steps 2 //AllowHtml attribute is developed for Customer View Model class. public   class   CustomerViewModel {     [ Display (Name =  "Email" )]      public   string  Email {  get ;  set ; }     [ AllowHtml ]      public   string ...