We use Request.Url.GetLeftPart(UriPartial.Authority)
to get the domain part of the site. This served our requirement on http.
We recently change site to https (about 3 days ago) but this still returns with http://..
Urls were all changed to https and show in browser address bar.
Any idea why this happens?
The following example works fine and returns a string with "https":
var uri = new Uri("https://www.google.com/?q=102njgn24gk24ng2k");
var authority = uri.GetLeftPart(UriPartial.Authority);
// authority => "https://www.google.com"
You either have an issue with the HttpContext
class right here, or all your requests are still using http:
HttpContext.Current.Request.IsSecureConnection
property. If it is true, and the GetLeftPart
method still returns http for you, I think you won't get around a replacing here.You should also inspect the incoming URL and log it somewhere for debugging purposes.