Update global application example of AutoValidateAntiForgeryTokenAttribute (#17045)
* Update AutoValidateAntiForgeryToken example * Update anti-request-forgery.md Co-authored-by: Rick Anderson <3605364+Rick-Anderson@users.noreply.github.com>pull/17058/head^2
parent
90118dc449
commit
31a7548c20
|
@ -328,11 +328,22 @@ public class ManageController : Controller
|
|||
|
||||
Global example:
|
||||
|
||||
::: moniker range="< aspnetcore-3.0"
|
||||
|
||||
services.AddMvc(options =>
|
||||
options.Filters.Add(new AutoValidateAntiforgeryTokenAttribute()));
|
||||
|
||||
::: moniker-end
|
||||
|
||||
::: moniker range=">= aspnetcore-3.0"
|
||||
|
||||
```csharp
|
||||
services.AddMvc(options =>
|
||||
services.AddControllersWithViews(options =>
|
||||
options.Filters.Add(new AutoValidateAntiforgeryTokenAttribute()));
|
||||
```
|
||||
|
||||
::: moniker-end
|
||||
|
||||
### Override global or controller antiforgery attributes
|
||||
|
||||
The [IgnoreAntiforgeryToken](/dotnet/api/microsoft.aspnetcore.mvc.ignoreantiforgerytokenattribute) filter is used to eliminate the need for an antiforgery token for a given action (or controller). When applied, this filter overrides `ValidateAntiForgeryToken` and `AutoValidateAntiforgeryToken` filters specified at a higher level (globally or on a controller).
|
||||
|
|
Loading…
Reference in New Issue