HtmlHelper.AntiForgeryToken Method ()

 

Generates a hidden form field (anti-forgery token) that is validated when the form is submitted.

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

Syntax

public MvcHtmlString AntiForgeryToken()
public:
MvcHtmlString^ AntiForgeryToken()
member AntiForgeryToken : unit -> MvcHtmlString
Public Function AntiForgeryToken As MvcHtmlString

Return Value

Type: System.Web.Mvc.MvcHtmlString

The generated form field (anti-forgery token).

Remarks

The anti-forgery token can be used to help protect your application against cross-site request forgery. To use this feature, call the AntiForgeryToken method from a form and add the ValidateAntiForgeryTokenAttribute attribute to the action method that you want to protect.

See Also

HtmlHelper Class
System.Web.Mvc Namespace

Return to top