Skip to main content
InterviewHubPRO
Section Overview
Q30

Question 30 of 50

Part 3: Distributed Systems, Kestrel Internals & Scalability (25 - 35)

60%
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] or IAntiforgery for cookie-authenticated web apps. Stateless JWT APIs sending Bearer headers are inherently immune.