Questions tagged [spcontext]
13 questions
7
votes
3 answers
Getting SPContext inside event receiver
I created an Event Receiver, but the problem is that I can't get a reference to the SPContext: SPContext.Current returns null. I need it to add some lists to the site. Does anyone have an idea of how I could get it?
Also I tried putting break…

Dr.Denis McCracleJizz
- 850
- 2
- 11
- 26
5
votes
1 answer
Wrong SPContext in Wcf Service
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()
{
…

Grant
- 2,295
- 3
- 14
- 13
4
votes
4 answers
What the difference between SPContext.Current.Web.Site.OpenWeb().Lists["List"]; and SPContext.Current.Web.Lists["List"]?
I have to refactor some sharepoint 2010 code from my collegue. Everytime he needs to access a list he does this:
SPContext.Current.Web.Site.OpenWeb().Lists["List"];
I used to do this:
SPContext.Current.Web.Lists["List"];
What's the difference…

LMW-HH
- 1,193
- 2
- 15
- 31
4
votes
2 answers
SPWeb.Url returns wrong URL
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…

Jason
- 41
- 1
- 2
2
votes
1 answer
SPContext in Event Receiver (PortalSiteMapProvider)
I'm trying to write an event receiver which uses the PortalSiteMapProvider. Without having HTTPContext or SPContext INSIDE the event receiver, how would one go about accessing the PortalSiteMapProvider?

LB.
- 13,730
- 24
- 67
- 102
1
vote
0 answers
SharePoint access with Hightrust-add-in, SharePoint hosted custom WCF Service, Current User NULL
I am working with an Azure hosted WebSerice which authenticates with an ADFS and creates an user access bearer token for communication with an on-premise SharePoint via a provider-hosted-add-in.
I can access SharePoint data via standard SharePoint…

A.P.
- 11
- 2
1
vote
4 answers
SharePoint SPContext.List in a custom application page
I have a custom SharePoint application page deployed to the _layouts folder. It's a custom "new form" for a custom content type. During my interactions with this page, I will need to add an item to my list. When the page first loads, I can use…

Chris Farmer
- 24,974
- 34
- 121
- 164
1
vote
1 answer
No current context when creating a sharepoint site
I've added a feature to my onet.xml file which gets activated whenever a site gets created. However, that feature needs to know the url of the site being created. I thought I could figure that out from the current SPContext within the activation…

user247417
- 11
- 2
1
vote
1 answer
SPContext.Current.Web.Url returns http instead of https
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…

Nasruddin Shaikh
- 11
- 1
- 2
1
vote
2 answers
CurrentUser is null on Sharepoint 2010 application page
I have application page, hosted on Sharepoint server (for ex. http://myportal/mysite/_layouts/application/default.aspx), which has code like this:
protected void Page_PreLoad(object sender, EventArgs e)
{
var userEmail =…

Tannheuser
- 416
- 5
- 16
0
votes
1 answer
Access a MySite Blog from a home page webpart
I've been away from SharePoint development for quite a while now, and I'm trying to access the information in a SharePoint 2010 blog (from one of our users, within their "MySite") from a C# webpart which will reside on the homepage of the site. The…

ZombieSheep
- 29,603
- 12
- 67
- 114
0
votes
1 answer
SharePoint 2007 HttpHandler NullReferenceException using SPContext.Current.Site/Web when called from jQuery
I have the need to develop a custom HttpHandler in SharePoint. To start, I just coded up a simple example: http://pastebin.com/HXLjR2xT. On line 35 or 36 of that code I get a NullReferenceException thrown if I call my HttpHander page from jQuery.…

TehOne
- 2,569
- 3
- 26
- 36
0
votes
1 answer
Another lists on site (Sharepoint 2010)
This is a question I can't handle, so please, give me some advice.
Here is my code for getting names of all lists:
private List GetAllLists()
{
site = SPContext.Current.Site;
web = site.OpenWeb();
List…

Viaches
- 143
- 1
- 16