Represents the context of an HTTP request in Microsoft SharePoint Foundation.

learn more… | top users | synonyms

1
vote
0answers
552 views

Fake SPContext as a particular user

I am using this method of faking an SPContext: http://solutionizing.net/2009/02/16/faking-spcontext/ public static SPContext FakeSPContext(SPWeb contextWeb) { // Ensure HttpContext.Current if ...
2
votes
3answers
2k views

How to get full home page address of a site collection?

When I use SPContext.Current.Site.Url it returns "http://servername" I need the full homepage URL which is "http://servername/SitePages/Home.aspx" Does anyone know how to get this programmatically?
3
votes
2answers
2k views

SPContext.Current vs SPContext.GetContext

To get current SP objects (SPWeb, SPSite, SPList etc), I generally use SPContext.Current. In some situations, SPContext.GetContext is preferred because SPContext.Current have many objects null ...
7
votes
4answers
331 views

How do I get machine name off of the SPContext

Simple question... how do I get the machine name off of the SPContext object.
25
votes
1answer
19k views

Using SPContext.Current or using static URL

There are multiple ways to work in the SP object model. The starting point for instantiating objects looks different when you look at different developers. Many times I see people doing this: SPList ...
3
votes
1answer
2k views

Is SPContext.Current Supposed to Be null in Custom WCF Service?

Here is the scenario: Custom WCF Service deployed in SharePoint 2010 Site is using Claims Based authentication (FBA, NTLM) .svc is deployed to ISAPI in the hive Service is configured using custom ...
9
votes
4answers
1k views

Disposing and Closing SPWeb objects

I have used something like using (SPWeb web = SPControl.GetContextWeb(Context)) but while deploying the project it shows an error. While trying to figure out the cause I came across an msdn ...
0
votes
2answers
3k views

What is the most effecient way to get the current server name?

I need to determine the 'main' server name based on the My Site server name in a control. This control needs to work in multiple environments with a different set of servers in each. Example: My ...
0
votes
3answers
690 views

SPContext returns wrong user account [closed]

I'm creating a web part on a non local server and I need to get the current user logged in to SharePoint. I'm using the following code to get the username. string currentUser = ...
11
votes
3answers
2k views

Should I dispose these SPSite and SPWeb objects?

Is it necessary to dispose the site and web objects in the following code? If so, how do I do this? Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load Dim site ...