I am making a call to a Web service on the initial load of the page through an Angular JS Service. The Web service calls a DLL where I am accessing SPContext.Current. If I am allowing the application to run without debugging, the object comes up as null.

Next what I did was I did a quick watch on SPContext.Current, and sure enough it came up null. But to my surprise when I did a quick watch on it again, the value was there. This was during the same debugging session.

Does anyone have any idea why the value appears when I am doing a second quick watch on SPContext.Current.

  • I had tried this earlier by calling the web service explicitly. But it didn't help. – Ritwik Sen Nov 2 '14 at 12:31
  • I had a similar issue with WCF service hosted in SP 2010. I eventualy ended up opening SPWeb in service ctor and disposing the it after call, i.e. I didn't use SPContext at all. This didn't introduce performance issues. – Slaven Semper Nov 2 '14 at 20:31
  • SPContext relies on a valid HTTPContext, if that helps. – Boland Nov 2 '14 at 22:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.