4

I have a web application in SharePoint that has been extended to another zone (Extranet). The access URL for the default zone is http ://server1, and the URL for the extranet zone is https: //www.server1.com.

Now, when I access the site via the extranet zone, I find that SPContext.Current.Web.Url returns http ://server1. I would have expected https ://www.server1.com, since that's how I'm accessing the site. What am I doing wrong?

Jason
  • 41
  • 1
  • 2
  • That's interesting - I have an alternate access mapping on a different port (`http://example` vs `http://example:8387`) and SPContext.Web.Url performs as expected. – Chloraphil Jan 20 '10 at 21:41

2 Answers2

1

Try using:

SPContext.Current.Site.MakeFullUrl(SPContext.Current.Web.ServerRelativeUrl);

That should take into account your access mappings.

Johan Leino
  • 3,473
  • 1
  • 26
  • 27
0

Odd...

As an alternative, have you tried using HttpContext.Current.Request.Url ?

zincorp
  • 3,284
  • 1
  • 15
  • 18