Request.URL always returns http even though SSL is

2020-07-09 07:22发布

问题:

I have prepared an ASP.NET web application (ASP.NET V2.0) and I configured it in my IIS (V7.5). I used Request.Url.AbsoluteUri in my application and it works fine in my server. I deployed the web application on my client's server machine (2008 R2 Server). But in my client's environment Request.Url.AbsoluteUri always return http url even though they enabled SSL. Whether any IIS settings configured on my client's server machine? Please guide me

回答1:

I have seen this before. The reason was that the load balancer at the production site terminated the SSL connection. It by itself connected to IIS using HTTP only. This scheme is a way to offload the SSL computations to the load balancer. It means that the IIS application does never see the HTTPS protocol although the browser does see it.

As spender pointed out in the comments, please see the HTTP headers arriving at your application. The load balancer is likely to add information to them that allows you to reconstruct everything.



回答2:

If you want to check whether request is HTTP or HTTPS. You should check headers. Below link really helped me to solve it.

http://www.bugdebugzone.com/2013/12/identifying-https-or-ssl-connection-in.html