Mid
From PDF
MVC
ASP.NET Core MVC
Anti-Forgery Tokens ● Protects against CSRF attacks ● In Razor: <form method="post"> @Html.AntiForgeryToken() </form> ● In API: use services.AddAntiforgery(), validate via [ValidateAntiForgeryToken]. 1⃣
Short answer: Anti-Forgery Tokens Protects against CSRF attacks In Razor: <form method="post"> @Html.AntiForgeryToken() </form> In API: use services.AddAntiforgery(), validate via [ValidateAntiForgeryToken]. 1⃣
Real-world example (ShopNest)
ShopNest’s product edit form posts to an MVC action. Model binding fills a ProductEditVm; the action validates and redisplay the view on errors.
Say this in the interview
- Define — one clear sentence (the short answer above).
- Example — relate it to a project like ShopNest or your real work.
- Trade-off — when you would not use it.
Share this Q&A
Share preview image: https://www.toolliyo.com/images/toolliyo-logo.png