c# https mvc

i use @HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Authority) but it does not read https. it read http only. how to fix it?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ITsolutionWizardAuthor Commented:
no one here to help out?
So if I understand you correctly, you have a site in ASP.NET / C#, and you're accessing it securely, like https://www.yourdomain.com/something.aspx and you want HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Authority) to return "https://www.yourdomain.com" but it's returning "http://www.yourdomain.com".

The first thing to do is double-check the IsSecureConnection property:

If that says false, but your browser shows https:// in the address bar, then probably what's happening is that you've got SSL terminated at some other intermediate server, like an f5. It's pretty common with load balancers or security appliances.

In other words, the browser is not talking directly to your web server - it is talking to another server that sits IN FRONT OF your web server. Then that other server is handling all the SSL, and is relaying the unencrypted request back to your web server. So your code always and only sees HTTP, not HTTPS requests (which can be okay if it's all within your own network):

[ Your Web Server ] <--- HTTP ---> [ Load Balancer ] <--- HTTPS ---> [ Browser ]
\_________________________________________________/ \_______________/
                  YOUR NETWORK                       PUBLIC INTERNET

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.