-
Book Overview & Buying
-
Table Of Contents
ASP.NET Web API Security Essentials
By :
Anti-forgery tokens or request verification tokens are used in ASP.NET MVC to avoid CSRF attack. Anti-forgery tokens or request verification tokens help in preventing the CSRF attacks. The .Net framework has a built-in support to create and validate anti-forgery tokens. The @Html.AntiForgeryToken() method in the MVC Razor engine creates the anti-forgery tokens. The validation of an anti-forgery token can be achieved by decorating the controller or action with the [ValidateAntiForgeryToken] attribute.
Let's see how the server accepts or rejects a request based on the anti-forgery token. Given in the following are the steps that are involved in making the anti-forgery token work:
The client sends a request for an MVC view with the form.
The server returns the requested view along with two tokens, one sent via cookie and other sent by setting to a hidden field in the form of the view.
These two tokens will be...
Change the font size
Change margin width
Change background colour