Jump to content

SharePoint: SPContext.Current returns null for in SharePoint foundation 2010

- - - - -

  • Please log in to reply
1 reply to this topic

#1
mayasmitha

mayasmitha

    Newbie

  • Members
  • PipPip
  • 13 posts
Hi All,

I am using the below code to access the web-application from SharePoint.

SPWebApplication webApplication = SPContext.Current.Site.WebApplication;

it works fine with the SharePoint server 2010(MOSS2010). But when I work with SharePoint foundation 2010(WSS4.0) SPContext.Current always returns null.

Further this issue happens only when the feature is deployed to webapplication like http://servername:31148/sites/ProjectA. But when I debug the code in featureActivated then SPContext.Current is available. However it is null when I try to access it from anywhere else.

Can anyone tell me what could be the reason for this? and how can i resolve this issue?

Thanks and regards.
MayaSmitha

#2
TheCompBoy

TheCompBoy

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 272 posts
I found same question on StackOverflow.. It has one answear that might help you: SharePoint: SPContext.Current returns null for in SharePoint foundation 2010 - Stack Overflow

And here's an older question from stackoverflow that also might help you a bit: sharepoint - Feature Event has 'null' objects - Stack Overflow
Think my post we're usefull? Please take your time and press the Like button at my post, Big Thanks!
For great C# & Android tutorials visit my blogg: http://www.thecompboy.com/




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users