liveBook · Manning

Hsts header

As explained in .NET in Action, Second Edition

HTTP Strict Transport Security is a web security policy that tells browsers to access a site only through HTTPS.

HTTP Strict Transport Security (HSTS) tells browsers that a site is accessible only through HTTPS by returning the Strict-Transport-Security response header. Browsers cache this policy for the whole site, avoiding repeated HTTP requests and reducing exposure before an HTTP redirect can arrive. section 9.3

Enable HSTS only where its long-term browser-caching behavior is appropriate:

  • Avoid HSTS in frequently changing alpha, beta, or preproduction environments unless they match your production policy. section 9.3

Production-only activation

var app = builder.Build(); if (app.Environment.IsProduction()) { app.UseHsts(); }

How .NET in Action, Second Edition covers it

How deep it goes
Explains browser caching, threat reduction, environment selection, and ASP.NET Core activation, while deferring detailed header semantics.
Examples
Uses app.UseHsts() and AddHsts options for production activation and policy configuration.
What it assumes
Assumes HTTPS deployment and distinguishes production from frequently changing nonproduction environments.
What you can do after
Operate/configure ASP.NET Core services to emit HSTS only in suitable production environments.
How it connects
Connects HTTPS, HTTP redirects, reverse proxies, certificates, browser caching, and man-in-the-middle attacks.

Also explained in

Compare how 5 books explain hsts header →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of .NET in Action, Second Edition. The section links point to the parts of the book it draws on.