I have asp.net application hosted on server, Is there any way to find out whether users come from HTTPS or HTTP,I have tried URL referrer but seems its not working for request coming from HTTPS to HTTP.
Please suggest some way out?
I have asp.net application hosted on server, Is there any way to find out whether users come from HTTPS or HTTP,I have tried URL referrer but seems its not working for request coming from HTTPS to HTTP.
Please suggest some way out?
Do you need this for the purpose of forcing HTTPS? You may want to check out this answer - ASP.NET: best practice for redirecting to https
I'm using the URL Rewrite answer with great success.
The Referrer
header is a bit unreliable and not clearly specified. However, most clients will not populate the header if the origin page was served over https. That does not mean that you can assume that an empty header means it came from https, since there are other reasons why they might not have filled it, but it is an indicator.
Have you tried Request.UrlReferrer
Uri MyUrl = Request.UrlReferrer;
Response.Write("Referrer URL Port: " + Server.HtmlEncode(MyUrl.Port.ToString()) + "<br>");
Response.Write("Referrer URL Protocol: " + Server.HtmlEncode(MyUrl.Scheme) + "<br>");
Reference http://msdn.microsoft.com/en-us/library/system.web.httprequest.urlreferrer.aspx
Also take a look at this..
http://www.codeproject.com/Questions/104895/Is-there-any-alternative-for-UrlReferrer-and-HTTP_
and this http://msdn.microsoft.com/en-us/library/system.net.httpwebrequest.referer.aspx