dotnet / dotnet/AspNetCore.Docs

Clarify antiforgery service registration and middleware setup

Open
#36,185 7 comments 0 reactions 1 assignee Claimed by @tdykstra View on GitHub
aspnet-core/svc security/subsvc Source - Docs.ms
Dominant language
C#
Stars
13.1k
Forks
24.6k
Avg merge
1d 2h
Merged PRs (30d)
109

Description

### Description

In [this section](https://learn.microsoft.com/en-us/aspnet/core/security/anti-request-forgery?view=aspnetcore-9.0#antiforgery-in-aspnet-core):
> Antiforgery middleware is added...

is confusing. Me and my coworker thought that calling `AddRazorComponents` added the middleware as well and we were trying to troubleshoot the app for a long time, even after adding `UseAntiforgery` manually were confused. Experienced programmers might understand that the middleware is the developer's responsibility but people new to ASP.NET might find this information confusing.

### Page URL

https://learn.microsoft.com/en-us/aspnet/core/security/anti-request-forgery?view=aspnetcore-9.0

### Content source URL

https://github.com/dotnet/AspNetCore.Docs/blob/main/aspnetcore/security/anti-request-forgery.md

### Document ID

bffca13c-223f-c61f-9cb2-9da8811eecfa

### Platform Id

a2883bdf-f8ff-d4f0-ef3e-413f88c39bd2

### Article author

@tdykstra

### Metadata

* ID: 47b14f57-82ac-a2e2-cbc7-22a81a60f4ac
* PlatformId: a2883bdf-f8ff-d4f0-ef3e-413f88c39bd2
* Service: **aspnet-core**
* Sub-service: **security**

[Related Issues](https://github.com/dotnet/AspNetCore.Docs/issues?q=is%3Aissue+is%3Aopen+bffca13c-223f-c61f-9cb2-9da8811eecfa)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.