Skip to content

Instantly share code, notes, and snippets.

@inetbiz
Last active February 18, 2016 19:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save inetbiz/9712582 to your computer and use it in GitHub Desktop.
Save inetbiz/9712582 to your computer and use it in GitHub Desktop.
protected void Application_BeginRequest(Object sender, EventArgs e)
{
switch (Request.Url.Scheme)
{
case "https":
Response.AddHeader("Strict-Transport-Security", "max-age=31536000; includeSubDomains; preload");
break;
case "http":
var path = "https://" + Request.Url.Host + Request.Url.PathAndQuery;
Response.Status = "301 Moved Permanently";
Response.AddHeader("Location", path);
break;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment