Implementing request varification tokan

Adeel Mirza 121 Reputation points
2022-05-31T06:08:42.537+00:00

I have read some articles on preventing cross site requests within an webpage by using request verification token in MVC and ASP.NET Core application.
But is there a way to implement this token in a classic ASP.NET application

ASP.NET
ASP.NET
A set of technologies in the .NET Framework for building web applications and XML web services.
3,253 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Lan Huang-MSFT 25,471 Reputation points Microsoft Vendor
    2022-05-31T09:26:11.13+00:00

    Hi @Adeel Mirza ,
    You can implement it like in asp.net mvc.

    • Generate a token on the server and store it (e.g. in the session)
    • send token to client
    • The client sends it back to the server along with the "normal" form data
    • Check the token on the server if needed

    You can refer to the following documents:
    Preventing Cross-Site Request Forgery (CSRF) Attacks in ASP.NET MVC Application
    https://learn.microsoft.com/en-us/aspnet/web-api/overview/security/preventing-cross-site-request-forgery-csrf-attacks
    XSRF/CSRF Prevention in ASP.NET MVC and Web Pages
    https://learn.microsoft.com/en-us/aspnet/mvc/overview/security/xsrfcsrf-prevention-in-aspnet-mvc-and-web-pages
    Best regards,
    Lan Huang


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.