简体   繁体   中英

how to redirect to same domain from http to https

how to redirect to same domain from http to https in the application_beginrequest event in a class file complied as dll using c#.

i cant redirect to the same server... any suggestion...

//Check if page is running under https. If not redirect to secure page...
if ((!HttpContext.Current.Request.IsSecureConnection))
{
    HttpContext.Current.Response.Redirect("https://" + Context.Request.Url.Host + Context.Request.Url.PathAndQuery);
}
if (Request.Url.ToString.ToLower.StartsWith("http://")) {
    Response.Redirect(Request.Url.ToString.Replace("http://", "https://"));
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM