AntiForgery.GetHtml Method

Definition

Overloads

GetHtml()

Adds an authenticating token to a form to help protect against request forgery.

GetHtml(HttpContextBase, String, String, String)
Obsolete.

Adds an authenticating token to a form to help protect against request forgery and lets callers specify authentication details.

GetHtml()

Adds an authenticating token to a form to help protect against request forgery.

public static System.Web.HtmlString GetHtml ();
static member GetHtml : unit -> System.Web.HtmlString
Public Shared Function GetHtml () As HtmlString

Returns

Returns a string that contains the encrypted token value in a hidden HTML field.

Exceptions

The current HttpContext object is null.

Applies to

GetHtml(HttpContextBase, String, String, String)

Caution

This method is deprecated. Use the GetHtml() 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.

Adds an authenticating token to a form to help protect against request forgery and lets callers specify authentication details.

[System.Obsolete("This method is deprecated. Use the GetHtml() 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 static System.Web.HtmlString GetHtml (System.Web.HttpContextBase httpContext, string salt, string domain, string path);
static member GetHtml : System.Web.HttpContextBase * string * string * string -> System.Web.HtmlString
Public Shared Function GetHtml (httpContext As HttpContextBase, salt As String, domain As String, path As String) As HtmlString

Parameters

httpContext
HttpContextBase

The HTTP context data for a request.

salt
String

An optional string of random characters (such as Z*7g1&p4) that is used to add complexity to the encryption for extra safety. The default is null.

domain
String

The domain of a web application that a request is submitted from.

path
String

The virtual root path of a web application that a request is submitted from.

Returns

Returns the encrypted token value in a hidden HTML field.

Attributes

Exceptions

httpContext is null.

Applies to