Reputation: 11
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...
Upvotes: 1
Views: 1090
Reputation: 48547
//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);
}
Upvotes: 1
Reputation: 13633
if (Request.Url.ToString.ToLower.StartsWith("http://")) {
Response.Redirect(Request.Url.ToString.Replace("http://", "https://"));
}
Upvotes: 0