Archive

Posts Tagged ‘http’

Redirect to https:// from http in ASP.net

February 15, 2011 1 comment

Hi Friends,
In some cases if you want to redirect the request from Non-secured to secured page.
Add following code in your page or master page.

if(!Request.IsSecureConnection)
{
string redirectUrl = Request.Url.ToString().Replace("http:", "https:");
Response.Redirect(redirectUrl);
}

This will redirect to same page with HTTPS.

Categories: Asp.net Tags: , , ,