Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [spsite]

A member of the Microsoft.SharePoint namespace, SPSite 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.

0
votes
2answers
47 views

SPSite can't find site

We recently began using a load balancer to force HTTPS on our SharePoint, and the PowerShell code below can no longer find the site. I've tried using both https://mysite and //mysite, with the same ...
0
votes
1answer
26 views

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") ...
1
vote
1answer
51 views

After create site collection with powershell UI is broken

After creating a site collection with PowerShell UI is broken. My PowerShell code is New-SPSite -Url $SiteColl_URL -OwnerAlias $SiteColl_Owner -Language 1033 -Template "CMSPUBLISHING#0" -Name $...
1
vote
2answers
165 views

Powershell cannot get SPSite after created it

After created site collection in PowerShell with this command: $SiteCollection = New-SPSite -Url $WebAPP.Url -OwnerAlias $SiteColl_Owner -Language 1033 -Template $SiteColl_Template -Name $...
1
vote
2answers
2k views

C# to check if the current login user have contributor access for SP site

I need to check the currently logged in user having the create list permission or not. suggest some idea .
0
votes
1answer
37 views

Exception User-Unhandled, Creation of SPSite objects with a different site id or a different user token is not allowed

I am creating a event handler that will sync documents between two sites on the same site collection when one is uploaded. This is the item added handler. public override void ItemAdded(...
0
votes
1answer
253 views

Getting error - Exception calling “Rename” with “1” argument(s): “Could not rename this site collection. The URL specified is already in use.”

I'm trying to rename an SPSite to a URL that had been previously deleted. So I go like this (note - urls redacted) $site = get-spsite <mysecondurl> $site.rename('myfirsturl') However, when ...
0
votes
1answer
3k views

Where will EnsureUser() method add users, and how it is going to validate users

I was searching for a method which returns SPUser object based on the display name of the user, and I found the EnsureUser() method. as I want to use this method inside my SharePoint server 2013 event ...
0
votes
1answer
25 views

incorrect documentation about the SPItemEventProperties.OpenWeb() method inside visual studio 2012

I have the following event receiver which will get fired when a custom list item is created, and the event receiver is scoped at the site level.:- public override void ItemAdded(...
3
votes
1answer
124 views

Cannot get Webs of SPSite object

I try to get all webs of an SPSite (via Powershell) on a SharePoint 2010. First I tried to get all the webs like this: $site = Get-SPSite http://<url> $webs = $site.AllWebs Every time tried ...
1
vote
1answer
106 views

How to get Site Collection name(or type)?

I`m making a windows application that analyse the SharePoint site. In SPSite Level, I want to get Site Collection name. Which means, I already got Site template name like this STS. private string ...
0
votes
2answers
2k views

How can I get Site Collection name(or title) in SPSite level using C#

I am a newbie in SharePoint, and now I`m trying to make a Winform application that analyse the SharePoint site. My application works like this. Type target site url in text box and click button ...
1
vote
1answer
408 views

How do I differentiate between getchanges REST API call for SPSite and SPWeb?

I'm trying to query SPSite for changes but I can't seem to figure out the difference between that and querying SPWeb. I'm following this documentation https://msdn.microsoft.com/en-us/library/...
2
votes
1answer
148 views

Recommended way/Best Practice to create a sub-site with RunWithElevatedPrivileges inside my Event Receiver

I am a bit confused if i am breaking the sharepoint best practice inside my sharepoint 2013 event receiver. now i have the following general requirements:- site collection url = http://servrname/kb/...
5
votes
1answer
503 views

New-SPSite User cannot be found - SharePoint 2013 Remote PowerShell

I am using Remote PowerShell Session to create SharePoint Site. The client computer is not part of AD forest. I have used the following PowerShell commands to enter into the remote session. $cred = ...
2
votes
1answer
477 views

When to dispose SPWeb and SPSite objects

I am writing code in feature receiver, and I am wondering when to dispose SPWeb and SPSite objects. For example, I have this in my code: SPWeb web = properties.Feature.Parent as SPWeb; Do I ...
4
votes
4answers
151 views

SP - What is the reason to use “using” in WebParts

I want to know, what is the reason to use "Using" like this: using (SPSite oSite = new SPSite("www.contoso.com")) { using (SPWeb oWeb = oSite.OpenWeb()) { **my code here......** } } How ...
0
votes
1answer
22 views

SPsite returning access error for an url different than the called one

I wrote a small C# .Net 4.5.2 application to rename some doc libraries. It fails at the very beginning: using(SPSite sitecoll=new SPSite("http://192.168.0.14:8069")) with the message Web ...
3
votes
3answers
184 views

Create a Field that only accepts SharePoint groups

I need to create a SharePoint 2013 field that only accepts groups (from SP, not AD). I know I can add UserSelectionMode="PeopleOnly" to make it accept only people, but I want the opposite. Is there ...
3
votes
2answers
961 views

Problem with RunWithElevatedPrivileges and Context

I'm trying to modify two properties I have in several documents in my SharePoint library. This is the code I use to get into the library: public SPArchiveBDI(string sharepointsite, string ...
0
votes
2answers
131 views

Dispose the correct SPSite object for garbage collection

I have these lines of code: string siteUrl = "http://myTestSite"; using (SPSite siteCollectionParent = new SPSite(strUrl)) { SPWebApplication webApplication = siteCollectionParent.WebApplication; ...
2
votes
2answers
4k views

Using Get-SPSite -Filter

I seem to be having some trouble using the Filter parameter on the Get-SPSite cmdlet. Using this question for reference, I'd hoped to filter out the Site that I was getting, to later on exclude it ...
1
vote
2answers
466 views

How can you change a rootweb name, url etc?

How can I change the name on a root web? Right now it's http://dev1/sites/dog. I am trying to change it to http://dev1/sites/cat I have tried $web = get-spweb http://dev1/sites/dog $web.Name = "...
1
vote
1answer
99 views

Effect of using multiple SPSite and SPWeb objects

I want to know that what effects will cause if I open SPSite and SPWeb objects more than once in a code file (c#) I have a implementation like below, can anyone tell me that what effects will it ...
2
votes
2answers
214 views

Need comments for code within SPSecurity.RunWithElevatedPrivileges

I am investigating the below code to make sure if its quality is as per Microsoft standards. Actually Comments came from Microsoft code reviewer that we need to create new SPSite Object within the ...
1
vote
0answers
104 views

Timeout using SPsite object and U2U Caml query

We have 2 collection. 1 is test and other is production environment. In test collection, I'm writing console application which is using SPSite and SPWeb objects. But it takes nearly 40minutes to get ...
0
votes
1answer
849 views

Create a site collection in root path with PowerShell

I am trying to create a new site collection with powershell in the root path http://mysite/search/ $siteName = "Search"; $webAppUrl = "http://sharepoint"; $siteUrl = "$webAppUrl/$siteUrl";...
4
votes
1answer
193 views

Using Visual Studio, how can I reference a SharePoint 2010 site collection outside of the development machine?

I am creating a custom web service which needs to reference a specific site collection on our SharePoint 2010 farm. The web service is on a development machine not part of the farm (although ...
0
votes
1answer
546 views

Move-SPSite: Cannot find an SPSite object with ID or Url

One of my sites has grown large, and I want to move it to a new Content DB. I've created a new content db, ResearchDB, successfully added it to SharePoint (New-SPContentDatabase), and checked Get-...
0
votes
2answers
426 views

I am getting Cannot find an SPSite that contains the following…Error

I have a PowerShell script below: Add-PSSnapin Microsoft.SharePoint.PowerShell function Get-DocInventory([string]$siteUrl) { $web = Get-SPWeb "http://contoso.com/sites/Test10" ...
0
votes
1answer
54 views

is either new SPSite(string url) or new SPSite(GUID guid) better than the other? how

I have cached access to either the Url or the GUID for multiple SharePoint site collections (SPSites), and I am trying to create new references to them for permissions purposes (SPSite constructor). ...
1
vote
0answers
74 views

Programmatically created SPWebApplication's WebParts not registered as safe

I am having a frustrating issue with a programmatically created web application in which a programmatically deployed solution's web parts are not registered as safe when adding to a programmatically ...
0
votes
2answers
28 views

Ideas underpinning SPSite and SPWeb [duplicate]

Edit: I'm not sure this will help, but I'll try: I am asking "what's the whole idea with wheels?"; a list of wheel parts is not what I am after. /edit I'm aware that SPSite - despite the confusing ...
2
votes
2answers
405 views

SPSite.Exists always returns false

I am trying to determine if a site collection exists, but the SPSite.Exists method always seems to return false regardless if the site collection exists or not. Snipp: bool exists; Uri uri = new Uri(...
1
vote
0answers
113 views

Best practice for re-using the SPWeb object across code layers/services

I have several services that use the SPWeb object. These services are called to perform various functions, sometimes completely unrelated. i.e. an AuthenticationService uses SPWeb to get information ...
1
vote
1answer
268 views

Determine if object is SPSite or SPWeb

I have a simple question, how to determine with PowerShell if a SharePoint Site is a SPSite object or SPWeb? I get all Site followed by user but some are SPSite.
0
votes
1answer
1k views

The language is not supported on the server

I installed Language Packs for SharePoint Server 2010 from: https://www.microsoft.com/en-us/download/details.aspx?displaylang=en&id=3411 On creating a new site collection using PowerShell with ...
1
vote
3answers
9k views

Site.OpenWeb() VS Site.RootWeb()

Just want to clarify between the two: what web variable will hold in both cases: SPWeb web = Site.OpenWeb(); SPWeb web = Site.RootWeb();
0
votes
1answer
1k views

how to get spsite title only

Right now my code gets the URL from my SPSite but I only want to get the Title var url = portalUrl.Text; if (SPSite.Exists(new Uri(url))) { using (SPSite oSiteCollection = new SPSite(url)) { ...
0
votes
1answer
206 views

Why is IsCurrentUserMemberOfGroup throwing an exception when run on SPSite.RootWeb?

Running this code in PowerShell (or even in a web context in C#) gives an unexpected behavior: Calling IsCurrentUserMemberOfGroup directly on the RootWeb object gives an exception, and worse: it ...
3
votes
1answer
2k views

Maximum length of SPSite Name and Description property values

Is there any reference to the maximum size for the Name and Description properties of a site collection?
6
votes
1answer
588 views

Setting an SPSite to read-only from Application Page

We are trying to make a site read-only from the code-behind of an application page. When executing the code-snippet from a timer job or a console application it works perfectly, but it throws an ...
0
votes
0answers
212 views

Cannot connect to my SPSite

I'm facing a strange issue. I have a console application project and added assembly Microsoft.SharePoint from C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\ISAPI\Microsoft....
2
votes
1answer
2k views

Microsoft SharePoint is not supported with version 4.0.30319.1 of the Microsoft .Net Runtime

I am developing a windows service in C# and adding dll for SharePoint. I have added reference from C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\ISAPI\Microsoft.SharePoint....
3
votes
2answers
1k views

Get SPWeb at all the levels

I have a root site with sites at different levels(depth is unknown). How can I find all the SPWeb objects iterating till the deepest level. will the below code give me desired result ...
0
votes
1answer
702 views

Error while restoring Site Collection to the same server

I am trying to restore a site (http://server:7457) to another site (http://server:80) on the same server. I had took the backup of the first site using SharePoint Administration Central. When I ...
2
votes
2answers
14k views

What is difference between SPContext.Current.Web.URL and SPContext.Current.Site when using SPSite object?

SPSite spsite1=new SPSite(SPContext.Current.Web.URL); SPSite spsite2=SPContext.Current.Site; What is the difference and when do we decide which one to use? I feel both give us the site collection ...
1
vote
4answers
924 views

SPSite URL value

Hello I am trying to fetch a list item and want to know if this is a good practice. SPSite spsite = new SPSite(SPContext.Current.Web.Url); SPWeb spWeb = spsite.RootWeb; ...
1
vote
1answer
77 views

Can we put an SPWeb object into a SPSite object?

This is possible: using (SPSite site = new SPSite(SPContext.Current.Site.WebApplication.Sites[0].Url)) Is this possible?: using (SPSite site = new SPSite(SPContext.Current.Site.WebApplication....
0
votes
1answer
1k views

What is difference between SPSite.Url and SPSite.RootWeb.Url

What is difference between: SPSite.Url SPSite.RootWeb.Url If both are same, Which is considered to be good practice?