Skip to main content
spelling mistake
Source Link
Dylan Young
  • 4.3k
  • 2
  • 25
  • 49

Handle BeginReuestBeginRequest event in Global.asax. This worked for me as rewrite module was absent on server.

protected void Application_BeginRequest(object sender, EventArgs e)
{                
    switch (Request.Url.Scheme)
    {
        case "https":
            Response.AppendHeader("Strict-Transport-Security", "max-age=31536000");
            break;
        case "http":
            var path = "https://" + Request.Url.Host + Request.Url.PathAndQuery;
            Response.Status = "301 Moved Permanently";
            Response.AddHeader("Location", path);
            break;
    }
}

Handle BeginReuest event in Global.asax. This worked for me as rewrite module was absent on server.

protected void Application_BeginRequest(object sender, EventArgs e)
{                
    switch (Request.Url.Scheme)
    {
        case "https":
            Response.AppendHeader("Strict-Transport-Security", "max-age=31536000");
            break;
        case "http":
            var path = "https://" + Request.Url.Host + Request.Url.PathAndQuery;
            Response.Status = "301 Moved Permanently";
            Response.AddHeader("Location", path);
            break;
    }
}

Handle BeginRequest event in Global.asax. This worked for me as rewrite module was absent on server.

protected void Application_BeginRequest(object sender, EventArgs e)
{                
    switch (Request.Url.Scheme)
    {
        case "https":
            Response.AppendHeader("Strict-Transport-Security", "max-age=31536000");
            break;
        case "http":
            var path = "https://" + Request.Url.Host + Request.Url.PathAndQuery;
            Response.Status = "301 Moved Permanently";
            Response.AddHeader("Location", path);
            break;
    }
}
deleted 110 characters in body
Source Link
Chris Auer
  • 13.2k
  • 1
  • 30
  • 87

Handle BeginReuest event in Global.asax. This worked for me as rewrite module was absent on server.

Handle BeginReuest event in Global.asax. This worked for me as rewrite module was absent on server.

protected void Application_BeginRequest(object sender, EventArgs e)
        {                
            switch (Request.Url.Scheme)
            {
                case "https":
                    Response.AppendHeader("Strict-Transport-Security", "max-age=31536000");
                    break;
                case "http":
                    var path = "https://" + Request.Url.Host + Request.Url.PathAndQuery;
                    Response.Status = "301 Moved Permanently";
                    Response.AddHeader("Location", path);
                    break;
            }
 
        }
Handle BeginReuest event in Global.asax. This worked for me as rewrite module was absent on server.

protected void Application_BeginRequest(object sender, EventArgs e)
        {                
            switch (Request.Url.Scheme)
            {
                case "https":
                    Response.AppendHeader("Strict-Transport-Security", "max-age=31536000");
                    break;
                case "http":
                    var path = "https://" + Request.Url.Host + Request.Url.PathAndQuery;
                    Response.Status = "301 Moved Permanently";
                    Response.AddHeader("Location", path);
                    break;
            }
 
        }

Handle BeginReuest event in Global.asax. This worked for me as rewrite module was absent on server.

protected void Application_BeginRequest(object sender, EventArgs e)
{                
    switch (Request.Url.Scheme)
    {
        case "https":
            Response.AppendHeader("Strict-Transport-Security", "max-age=31536000");
            break;
        case "http":
            var path = "https://" + Request.Url.Host + Request.Url.PathAndQuery;
            Response.Status = "301 Moved Permanently";
            Response.AddHeader("Location", path);
            break;
    }
}
Source Link

Handle BeginReuest event in Global.asax. This worked for me as rewrite module was absent on server.

protected void Application_BeginRequest(object sender, EventArgs e)
        {                
            switch (Request.Url.Scheme)
            {
                case "https":
                    Response.AppendHeader("Strict-Transport-Security", "max-age=31536000");
                    break;
                case "http":
                    var path = "https://" + Request.Url.Host + Request.Url.PathAndQuery;
                    Response.Status = "301 Moved Permanently";
                    Response.AddHeader("Location", path);
                    break;
            }

        }