How to switch from HTTP to HTTPS automatically in ASP.NET?
Also no need to do same thing in Local connection
How to switch from HTTP to HTTPS automatically in ASP.NET?
Also no need to do same thing in Local connection
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!