SPContext.Current.Web.Url returns http instead of https

2.7k views Asked by At

I have developed several webparts, where i used SPContext.Current.Web.Url to get the web url. It's working when access a site with hxxps://abc/ But i get http instead of https when accessed by IP.

Problem: When i access hxxps://172.1.25.25/ SPContext.Current.Web.Url returns hxxp://172.1.25.25/

When i access hxxps://abc/ SPContext.Current.Web.Url returns hxxps://abc/

My Alternate Access Mappings

hxxp://172.1.25.25/ Intranet

hxxps://172.1.25.25/ Intranet

hxxp://abc/ Internet

hxxps://abc/ Internet

I used several workaround which i got it in the Forum :( nothing worked, Thanks in Advance

1

There are 1 answers

0
Ryan On

In your AAM you will have one that is the "Public URL for zone" and this is what SPContext.Current.Web.URL will return - change it to https if that is the one you want to use.

SharePoint Central Admin > Application Management > Configure alternate Access Mappings > Edit Public URL's

MSDN - Configure alternate access mapping (Windows SharePoint Services)