security-headers

Configure security headers in ASP.NET Core Razor Pages applications.

71|10|Updated Feb 11, 2026
One-click install
npx skills add https://github.com/wshaddix/dotnet-skills --skill security-headers-wshaddix
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: security-headers
Source: https://github.com/wshaddix/dotnet-skills/tree/main/skills/security-headers
Command: npx skills add https://github.com/wshaddix/dotnet-skills --skill security-headers-wshaddix

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) and references (resource) components.

What problem does it solve?

This Skill helps you implement robust security headers in your ASP.NET Core applications to protect against common web vulnerabilities like XSS, clickjacking, and man-in-the-middle attacks.

Core Features & Use Cases

  • Configure essential security headers: CSP, HSTS, X-Frame-Options, X-Content-Type-Options, Referrer-Policy, and Permissions-Policy.
  • Implement Content Security Policy (CSP): Define granular rules for allowed content sources to mitigate XSS attacks.
  • Use Case: You are building a new ASP.NET Core web application and need to ensure it's protected against common web attacks by correctly configuring security headers.

Quick Start

Configure security headers for your ASP.NET Core application by adding the UseSecurityHeaders middleware to your pipeline.

Frequently Asked Questions about security-headers

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I configure security headers in an ASP.NET Core Razor Pages application?

To configure security headers in ASP.NET Core, you add the `UseSecurityHeaders` middleware to your application's request processing pipeline to apply policies like CSP and HSTS.

What is Content Security Policy (CSP) and how does it mitigate XSS in ASP.NET Core?

Content Security Policy (CSP) is an HTTP header that defines granular rules for allowed content sources, mitigating cross-site scripting (XSS) attacks by restricting where scripts can load from.

What HTTP headers do I need to protect my ASP.NET Core app against clickjacking?

To protect against clickjacking, you implement the X-Frame-Options header, which prevents your web pages from being embedded in unauthorized iframes by controlling frame rendering permissions.

Does this security headers middleware work with ASP.NET Core web applications?

Yes, this middleware is specifically designed for ASP.NET Core Razor Pages applications to set HSTS, CSP, X-Content-Type-Options, Referrer-Policy, and Permissions-Policy headers.

Why do I need HTTP Strict Transport Security (HSTS) for my web application?

HTTP Strict Transport Security (HSTS) enforces secure HTTPS connections, protecting your web application against man-in-the-middle attacks by forcing browsers to always use HTTPS.

What is the best way to set up comprehensive security middleware in ASP.NET Core?

The best way to establish comprehensive security middleware is using a centralized configuration approach that applies multiple headers simultaneously, ensuring protection against common web vulnerabilities.