AllowHtmlAttribute Class

Allows a request to include HTML markup during model binding by skipping request validation for the property. (It is strongly recommended that your application explicitly check all models where you disable request validation in order to prevent script exploits.)

Inheritance Hierarchy


Namespace:  System.Web.Mvc
Assembly:  System.Web.Mvc (in System.Web.Mvc.dll)


<AttributeUsageAttribute(AttributeTargets.Property, AllowMultiple := False,  _
    Inherited := True)> _
Public NotInheritable Class AllowHtmlAttribute _
    Inherits Attribute _
    Implements IMetadataAware
Dim instance As AllowHtmlAttribute
[AttributeUsageAttribute(AttributeTargets.Property, AllowMultiple = false, 
    Inherited = true)]
public sealed class AllowHtmlAttribute : Attribute, 
[AttributeUsageAttribute(AttributeTargets::Property, AllowMultiple = false, 
    Inherited = true)]
public ref class AllowHtmlAttribute sealed : public Attribute, 
public final class AllowHtmlAttribute extends Attribute implements IMetadataAware

The AllowHtmlAttribute type exposes the following members.


  Name Description
Public method AllowHtmlAttribute Initializes a new instance of the AllowHtmlAttribute class.



  Name Description
Public property TypeId (Inherited from Attribute.)



  Name Description
Public method Equals (Inherited from Attribute.)
Protected method Finalize (Inherited from Object.)
Public method GetHashCode (Inherited from Attribute.)
Public method GetType (Inherited from Object.)
Public method IsDefaultAttribute (Inherited from Attribute.)
Public method Match (Inherited from Attribute.)
Protected method MemberwiseClone (Inherited from Object.)
Public method OnMetadataCreated This method supports the ASP.NET MVC validation infrastructure and is not intended to be used directly from your code.
Public method ToString (Inherited from Object.)


Explicit Interface Implementations

  Name Description
Explicit interface implemetationPrivate method _Attribute.GetIDsOfNames (Inherited from Attribute.)
Explicit interface implemetationPrivate method _Attribute.GetTypeInfo (Inherited from Attribute.)
Explicit interface implemetationPrivate method _Attribute.GetTypeInfoCount (Inherited from Attribute.)
Explicit interface implemetationPrivate method _Attribute.Invoke (Inherited from Attribute.)



By default, the ASP.NET MVC framework checks requests during model binding to determine whether they contain potentially dangerous content as HTML markup. If HTML is detected, model binding throws an error.

If a property is marked with the AllowHtmlAttribute attribute, the ASP.NET MVC framework skips validation for that property during model binding. For more information, see the entry Granular Request Validation in ASP.NET MVC on Marcin Dobosz's blog.

Caution noteCaution:

Allowing HTML input is a potential security threat. For more information, see Script Exploits Overview.

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

See Also


System.Web.Mvc Namespace