Share via

IAntiforgery Interface


Provides access to the antiforgery system, which provides protection against Cross-site Request Forgery (XSRF, also called CSRF) attacks.

public interface class IAntiforgery
public interface IAntiforgery
type IAntiforgery = interface
Public Interface IAntiforgery



Generates an AntiforgeryTokenSet for this request and stores the cookie token in the response. This operation also sets the "Cache-control" and "Pragma" headers to "no-cache" and the "X-Frame-Options" header to "SAMEORIGIN".


Generates an AntiforgeryTokenSet for this request.


Asynchronously returns a value indicating whether the request passes antiforgery validation. If the request uses a safe HTTP method (GET, HEAD, OPTIONS, TRACE), the antiforgery token is not validated.


Generates and stores an antiforgery cookie token if one is not available or not valid.


Validates an antiforgery token that was supplied as part of the request.

Extension Methods

GetHtml(IAntiforgery, HttpContext)

Generates an <input type="hidden"> element for an antiforgery token.

Applies to