Home > Back-end >  How to make a custom ValidateAntiForgeryTokenAttribute?
How to make a custom ValidateAntiForgeryTokenAttribute?

Time:04-15

I have looked everywhere but could not find code on how to create a custom AntiforgeryTokenAttribute using Asp.net Core. I've found examples based on older versions of Asp.net but not Core. I want to add some logic for when the token is validated to only validate based on some business rules. I've tried creating a new attribute inheriting AntiforgeryTokenAttribute but there doesn't seem to be any override that lets me control when to validate and when to ignore a forgery token.

CodePudding user response:

Maybe this can help you, it creates a custom attribute like antiforgerytoken https://stackoverflow.com/a/59550210/7071238

  • Related