I have SharePoint 2010 (_http://sp2010/, for instance). I have created site (_http://sp2010/site/) and WCF Service, which is hosted in ISAPI folder. In service I have such test method:
[OperationContract]
public string GetCurrentWebUrl()
{
return SPContext.Current.Site.Url + " | " + SPContext.Current.Web.Url;
}
I call service from my console application using this address - _http://sp2010/site/_vti_bin/WcfService.svc/mex. When calling method GetCurrentWebUrl I expect to get _http://sp2010/site/, but I always get _http://sp2010/. In other words SPContext is not correct.
What am I doing wrong? How can I get right context?
Can you double check that you are really calling http://sp2010/site/_vti_bin/WcfService.svc/mex
? When using the Visual Studio Add Service Reference dialog, it usually uses the root, as in http://sp2010/_vti_bin/WcfService.svc/mex
.
If you are setting it up in code it should indeed work, at least it does for me :(
What is SPContext.Current.Web.Url
and Web.ID
? Does that match the /site/ Web?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With