To detect the http or https scheme in ASP.NET in server side code we can use Uri.Scheme property.Below is the sample code to do the same:
string url = "https://www.yourwebsite.com/";
Uri uri = new Uri(url);
string scheme = uri.Scheme;
The output of above code is "https"