ASP.NET Core & Web API (50 Qs)•Part 3: Distributed Systems, Kestrel Internals & Scalability (25 - 35)
How do you prevent Cross-Site Scripting (XSS) and Cross-Site Request Forgery (CSRF)?
senior LevelMost AskedSecurity & AuthSystem Design
In Simple Words:
- XSS: Razor and Blazor encode HTML output by default. Configure strict Content Security Policy (CSP) headers.
- CSRF: Use
[AutoValidateAntiforgeryToken]orIAntiforgeryfor cookie-authenticated web apps. Stateless JWT APIs sending Bearer headers are inherently immune.