ASP.net check if page is http or https

Viewed 40373

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?

7 Answers

Update for Aspnet Core 2.0, now, you should use Request.IsHttps inside your controllers.

In .net core I use:

Context.Request.Scheme == Uri.UriSchemeHttps
Related