I m going to use load balancer so as i see there is nice code for this:
public virtual bool IsCurrentConnectionSecured()
{
bool useSsl = false;
if (IsRequestAvailable(_httpContext))
{
//when your hosting uses a load balancer on their server then the Request.IsSecureConnection is never got set to true
//1. use HTTP_CLUSTER_HTTPS?
if (!string.IsNullOrEmpty(ConfigurationManager.AppSettings["Use_HTTP_CLUSTER_HTTPS"]) &&
Convert.ToBoolean(ConfigurationManager.AppSettings["Use_HTTP_CLUSTER_HTTPS"]))
{
useSsl = ServerVariables("HTTP_CLUSTER_HTTPS") == "on";
}
//2. use HTTP_X_FORWARDED_PROTO?
else if (!string.IsNullOrEmpty(ConfigurationManager.AppSettings["Use_HTTP_X_FORWARDED_PROTO"]) &&
Convert.ToBoolean(ConfigurationManager.AppSettings["Use_HTTP_X_FORWARDED_PROTO"]))
{
useSsl = string.Equals(ServerVariables("HTTP_X_FORWARDED_PROTO"), "https", StringComparison.OrdinalIgnoreCase);
}
else
{
useSsl = _httpContext.Request.IsSecureConnection;
}
}
return useSsl;
}
But the question is how to setup HTTP_CLUSTER_HTTPS server variable?