Donny V.
Donny V.

Reputation: 23546

How to make a custom ValidateAntiForgeryTokenAttribute?

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.

Upvotes: 1

Views: 2252

Answers (1)

Ali Yetkin
Ali Yetkin

Reputation: 76

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

Upvotes: 4

Related Questions