Create a gist now

Instantly share code, notes, and snippets.

@inetbiz /iis-hsts
Last active Feb 18, 2016

What would you like to do?
protected void Application_BeginRequest(Object sender, EventArgs e)
switch (Request.Url.Scheme)
case "https":
Response.AddHeader("Strict-Transport-Security", "max-age=31536000; includeSubDomains; preload");
case "http":
var path = "https://" + Request.Url.Host + Request.Url.PathAndQuery;
Response.Status = "301 Moved Permanently";
Response.AddHeader("Location", path);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment