ValidateAntiForgeryToken

Hello,

In Umbraco version 10, I would like to Validate anti forgery token before handling every method. So I tried to use:

[HttpPost]

[ValidateAntoForgeryToken]

public IActionResult HandleMyMethod(MyModel model)

{


}

*I know that [ValidateAntoForgeryToken] is not needed here, because AntiForgeryToken is used by default.

My problem is that if my auth token is expired, then the user gets error 400. I want him to get an error, but in a “beautiful” way. Or instead, I want to redirect him to login page.

My question is, is it possible? to put

[ValidateAntoForgeryToken]

Over a method, and write a code somewhere that will redirect the user to the login page if [ValidateAntoForgeryToken] returns error?

Thank you so much!!!


This is a companion discussion topic for the original entry at https://our.umbraco.com/forum/113145-validateantiforgerytoken