-1

How to switch from HTTP to HTTPS automatically in ASP.NET?

Also no need to do same thing in Local connection

RASKOLNIKOV
  • 732
  • 2
  • 9
  • 20

1 Answers1

0

Lets start:

Open Global.asax code finde Application_BeginRequest,change it like this:

 protected void Application_BeginRequest(object sender, EventArgs e)
        {
            if (HttpContext.Current.Request.IsSecureConnection.Equals(false) && HttpContext.Current.Request.IsLocal.Equals(false))
            {
                Response.Redirect("https://" + Request.ServerVariables["HTTP_HOST"] + HttpContext.Current.Request.RawUrl);
            }
        }

Bingo!

RASKOLNIKOV
  • 732
  • 2
  • 9
  • 20