tags:

views:

304

answers:

3

I have a web application hosted on multiple servers some of which are on https. How can I check from code behind if a page is currently in http or https?

+10  A: 

You can refer to the Request.IsSecureConnection property on the HttpRequest class. For a full reference outside a page, user control or alike, use HttpContext.Current.Request.IsSecureConnection.

troethom
29 seconds... ;-)
Rashack
+2  A: 

Use - HttpContext.Current.Request.IsSecureConnection

Rashack
+1  A: 

Alternatively:

Request.ServerVariables["SERVER_PROTOCOL"];
Mr. Smith