-
Notifications
You must be signed in to change notification settings - Fork 2.1k
[IgnoreAntiForgeryToken] Not working in Razor Pages #7795
Comments
Dups #5863 but this keeps popping up, #6306, and I found more old issues and I followed the steps to work around it and expected it to be fixed (#5552) but now I read Order = 1000 isn't good enough but 1001 will fix it? Shouldn't this just work without having to fiddle with magic numbers? Since this is a known issue I will not share my repro. |
/cc @rynowak |
Did you try putting the filter attribute on the class? This is one of the things that's confusing about pages and we have plans to add an analyzer. |
Heck that works. But why is that necessary? Wouldn't it be better to
That saves writing the analyzer, too. It still fails if applied to the class without I feel Razor pages is a bit rigid in more places, such as only understanding conventions for handler names for example. I like to name methods so I can use nameof to create links... |
There's a couple of interaction issues here that sort of culminate in this behavior
The behavior is non-intuitive and it's not entirely obvious why a higher filter order should cause things to work. A couple of possible solutions to consider:
|
👍 |
We are not stupid - most of us, I only speak for myself - so there should be a way to make AntiForgery just go away. There is also this nice feature called authorization which can help. Or alternatively a way to have a blank class and no Just like I would like to point some factory at my web app without any context and get an |
The following suggestion is most appealing:
|
This is a no-go. We specifically rely on ordering to ensure that |
For 2.2.0, we'll honour |
Is this a Bug or Feature request?:
Bug
Steps to reproduce (preferrably a link to a GitHub repo with a repro project):
See below
Description of the problem:
Adding
[IgnoreAntiForgeryToken]
in a controller works as expected, however, adding it to a Razor Pages method has no effect.Version of
Microsoft.AspNetCore.Mvc
orMicrosoft.AspNetCore.App
orMicrosoft.AspNetCore.All
:2.1.0-rc1-final
Test Script
Output
The text was updated successfully, but these errors were encountered: