Share via


HtmlHelper.AntiForgeryToken Method

Definition

Overloads

AntiForgeryToken()

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

AntiForgeryToken(String)
Obsolete.

Generates a hidden form field (anti-forgery token) that is validated when the form is submitted. The field value is generated using the specified salt value.

AntiForgeryToken(String, String, String)
Obsolete.

Generates a hidden form field (anti-forgery token) that is validated when the form is submitted. The field value is generated using the specified salt value, domain, and path.

AntiForgeryToken()

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

public System.Web.Mvc.MvcHtmlString AntiForgeryToken ();
member this.AntiForgeryToken : unit -> System.Web.Mvc.MvcHtmlString
Public Function AntiForgeryToken () As MvcHtmlString

Returns

The generated form field (anti-forgery token).

Applies to

AntiForgeryToken(String)

Caution

This method is deprecated. Use the AntiForgeryToken() method instead. To specify custom data to be embedded within the token, use the static AntiForgeryConfig.AdditionalDataProvider property.

Generates a hidden form field (anti-forgery token) that is validated when the form is submitted. The field value is generated using the specified salt value.

[System.Obsolete("This method is deprecated. Use the AntiForgeryToken() method instead. To specify custom data to be embedded within the token, use the static AntiForgeryConfig.AdditionalDataProvider property.", true)]
public System.Web.Mvc.MvcHtmlString AntiForgeryToken (string salt);
member this.AntiForgeryToken : string -> System.Web.Mvc.MvcHtmlString
Public Function AntiForgeryToken (salt As String) As MvcHtmlString

Parameters

salt
String

The salt value, which can be any non-empty string.

Returns

The generated form field (anti-forgery token).

Attributes

Applies to

AntiForgeryToken(String, String, String)

Caution

This method is deprecated. Use the AntiForgeryToken() method instead. To specify a custom domain for the generated cookie, use the <httpCookies> configuration element. To specify custom data to be embedded within the token, use the static AntiForgeryConfig.AdditionalDataProvider property.

Generates a hidden form field (anti-forgery token) that is validated when the form is submitted. The field value is generated using the specified salt value, domain, and path.

[System.Obsolete("This method is deprecated. Use the AntiForgeryToken() method instead. To specify a custom domain for the generated cookie, use the <httpCookies> configuration element. To specify custom data to be embedded within the token, use the static AntiForgeryConfig.AdditionalDataProvider property.", true)]
public System.Web.Mvc.MvcHtmlString AntiForgeryToken (string salt, string domain, string path);
member this.AntiForgeryToken : string * string * string -> System.Web.Mvc.MvcHtmlString
Public Function AntiForgeryToken (salt As String, domain As String, path As String) As MvcHtmlString

Parameters

salt
String

The salt value, which can be any non-empty string.

domain
String

The application domain.

path
String

The virtual path.

Returns

The generated form field (anti-forgery token).

Attributes

Applies to