Questions tagged [spsite]

Represents a collection of sites in a Web application, including a top-level Web site and all its subsites.

Definition:

Represents a collection of sites in a Web application, including a top-level Web site and all its subsites. Each SPSite object, or site collection, is represented within an SPSiteCollection object that consists of the collection of all site collections in the Web application.

More reading:

Code example:

//providing an absolute URL, 
SPSite mySiteCollection = new SPSite("http://mysharepointsite/");

//using the current context
SPSite mySiteCollection = SPContext.Current.Site;

SPSite implements the IDisposable interface so you should close the object when you no longer need it. This is not the case when you're object is assigned with the Context. So in the second line, the Dispose() should not be called. You can close it manually or use the using statement to do this for you:

//manually
mySiteCollection.Dispose();

//using statement
using (SPSite mySiteCollection = new SPSite("http://mysharepointsite/")
{
    //your code here
}
37 questions
1
vote
1 answer

Sharepoint 2010 Show SPList on webpart from a remote SPSite

Im new to sharepoint and im trying to get a SPList from another SPSite i have on same farm, that itself is not a problem. But i want to do something like this:…
Nubbe
  • 13
  • 3
1
vote
5 answers

Programmatically Accessing SharePoint Style Library from within C#

Firstly, I'm a newbie to C# and SharePoint, (less than a month's experience) so apologies if this is an obvious or easy question but I've been trawling the net for a couple of days now with absolutely no success. I have an xslt file that I have…
pwmusic
  • 4,739
  • 4
  • 23
  • 14
1
vote
5 answers

Is possible to inherit from SPWeb?

Is possible to inherit from SharePoint classes such like: SPWeb, SPList etc. or this classes are sealed? I couldn't find right answer. Chris Thanks for replys. Rich, you are right - the constructors are internal. So it means that I coudn't extend…
Chris
  • 103
  • 1
  • 8
1
vote
1 answer

Dealing with Sharepoint locked Site Collections

I am playing with an application that can crawl the contents of sharepoint server. But I got a problem while working with Locked Site collections. There are some methods that cannot be used with locked site collections. It throws an exception…
Chathuranga Chandrasekara
  • 20,548
  • 30
  • 97
  • 138
1
vote
0 answers

Apply custom masterpage for a new site collection

This works for existing site collection and any new sites under it and their subsites BUT when I create a new site collection, well i can't even create a new site collection now as it gives me file not found error as the root site of my new…
Athapali
  • 1,091
  • 4
  • 25
  • 48
1
vote
2 answers

SPSite in Visual Studio 2010

So instead of banging my head against the wall for another couple of hours, I thought I'd just double check a few things here. First of all, I've been trying to access lists stored on a SharePoint 2007 server (which I should start off by saying is…
Nate Frueh
  • 79
  • 1
  • 8
0
votes
2 answers

I have an error in my code "the type or namespace name 'spsite' could not be found" that I have no idea how to solve it

I have write a code that contains SPSite and I got this error CS0246: The type or namespace name 'SPSite' could not be found (are you missing a using directive or an assembly reference?) I have tried downloading Microsoft.SharePoint from the nuget…
0
votes
1 answer

SharePoint 2013 - Getting SPSite.Url from SharePoint DB

I'm working directly against the SharePoint DB (I know it is highly not recommended but I need to, for several reasons). I'm trying to get the SPSite.Url property ("http://baseurl/sites/somename") but can't figure out how to do that. I can only find…
Amir M
  • 508
  • 1
  • 8
  • 28
0
votes
1 answer

Error While creating SPSite instance with SharePoint Foundation 2010

I'm getting the following error while trying to create a SPSite instance (not open it, just create it): "The Web application at could not be found. Verify that you have typed the URL correctly. If the URL should be serving existing content,…
0
votes
1 answer

Retrieve data for sub sites and child sites

I need to access following structure on SP server with following structure. I have tried SPWebApp, SPWeb, SPSite and GetSubwebsForCurrentUser but I am missing something and I am not able to get data past branch Trees. Please note that I do not have…
BeHappy
  • 138
  • 2
  • 17
0
votes
1 answer

Extracting SPWeb.Groups.Xml in XElement

I need to get SPWeb.Groups.Xml in XElement to create XDocument. SPSite site = new SPSite(url); foreach (SPWeb web in site.AllWebs) { SPUserCollection spusers = site.RootWeb.SiteUsers; XElement xeGroup =…
BeHappy
  • 138
  • 2
  • 17
0
votes
3 answers

SPSite constructor returns cached instance.

The SPSite constructor (new SPSite(mySiteId)) returns a cached entry, even though the site no longer exists. How can I prevent this?
kjv
  • 11,047
  • 34
  • 101
  • 140
0
votes
1 answer

Why does this Sharepoint Files.Add() result in an I/O Error?

With this code: using (var ms = new MemoryStream()) { using (var doc = new Document(PageSize.A4, 25, 25, 10, 10)) { //Create a writer that's bound to our PDF abstraction and our stream using (var…
0
votes
2 answers

Renamed the "Modify By" field after using Elevated Mode

I'm currently facing to an issue using the Elevated Mode used in a Feature. I have created a custome SharePoint security role (contribute role without the Delete right). The goal of my SharePoint feature is the following: When uploading a file to a…
fix105
  • 234
  • 1
  • 6
  • 16
0
votes
2 answers

SPList and SPSite name - different screen and file name - is it possible?

Is there a possibility to have different list or site display name (on screen) than the file name? I mean to display other name in left quick launch bar than the file names itself? For example I would name list like A on screen, and call it in my…
truthseeker
  • 2,214
  • 6
  • 30
  • 53