tags:

views:

247

answers:

2

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...

A: 
if (Request.Url.ToString.ToLower.StartsWith("http://")) {
    Response.Redirect(Request.Url.ToString.Replace("http://", "https://"));
}
Gordon Bell
+4  A: 
//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);
}
Ardman
Can this be done in the web.config?
Lieven Cardoen