Questions tagged [spweb]

SPWeb is a single website in SharePoint residing in a Site Collection (SPSite).

Filter by
Sorted by
Tagged with
1 vote
4 answers
6k views

Removing SPWeb properties from its property bag with powershell

I need to remove properties from multiple places with powershell script. I tried many examples from net, with null assigning and using remove on Properties and AllProperties, or using method ...
1 vote
3 answers
111 views

Is using the Using statement to close unknown and possibly Current webs, bad practice?

Until today I had been using the Using statement to open and dispose of webs. The variable relative_web_url is defined by a user input in the custom web part editor. using (SPWeb web = ...
0 votes
1 answer
909 views

Using EnsureUser with ADFS

I am trying to take some users and author them to list item posts. The SPWeb.EnsureUser() method works fine on a server only utilizing AD, but not one that is using ADFS. Here is my attempt at ...
0 votes
1 answer
211 views

The version of the package is different from the current version this program supports

Goog day, I have the problem with site import between two site collections. SharePoint 2016. The site collections are from same SP Farm. I exported the site "http://Coll1.xxx.com/career" using the ...
0 votes
1 answer
2k views

You cannot call a method on Null valued expression at: $File = $Web.GetFile([Guid]$Result.Id)

I have queried AllDocs table using Powershell and can see GUID values of Id, SiteId and WebId, But I am getting Error: You cannot call a method on Null valued expression at this line below: $File = $...
2 votes
2 answers
323 views

Dispose should not be called on this object. // SPDisposeCheck comment

In the code below, within using directive, for rootweb, Dispose(); method will be called implicitly, is that correct? Or should I need a using directive for this: SPWeb rootweb = site.RootWeb since I ...
1 vote
1 answer
1k views

How to get the URL of an item's parent web in JavaScript?

Given an absolute URL to an item, like: http://server/sites/mysite/myweb/Lists/MyList/DispForm.aspx?ID=1 or the absolute URL to the item's parent list, like: http://server/sites/mysite/myweb/Lists/...
1 vote
0 answers
492 views

_spBodyOnLoadFunctionNames.push Not working in firefox

I tried this in firefox i dont know why its not working but it working in other browsers function loadmonth() { alert('called'); } _spBodyOnLoadFunctionNames.push("loadmonth");
4 votes
5 answers
4k views

Disposal of SPWebs created using SPSite.OpenWeb()

After reading some answers/comments on Disposal of SPWebs retrieved from SPContext.Current.Site.AllWebs, I opened up Reflector to dig deeper into the SPSite and SPWeb classes. I ran into a surprise, ...
0 votes
1 answer
287 views

SPWeb object properties turn to "null reference exception"

I am currently working a Farm Solution that is supposed to work with SharePoint 2016 and I am facing something that I can't understand. Maybe someone could explain this phenomenon or point what I am ...
0 votes
1 answer
61 views

Should i use "using" inside event receiver

I'm confused if i should use the using statement inside an event because the event is "asynchronous" and the object can be disposed before ending the job. Or am i missing something public override ...
9 votes
2 answers
21k views

Getting SPWeb in feature receiver

While testing my solution I receive an error on Feature activation: Detected use of SPRequest for previously closed SPWeb object. Please close SPWeb objects when you are done with all objects ...
0 votes
1 answer
97 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
2 answers
759 views

Uncommitted changes on SPWeb object

In my simple Powershell script, I keep getting an error "Exception calling "ResetRoleInheritance" : There are uncommitted changes on the SPWEb Object, call SPWeb.Update() to commit the cahnges before ...
2 votes
3 answers
2k views

Error using current SPWeb from HttpModule

Is it allowed to access SPWeb and specifically SPWeb.ID from PreRequestHandlerExecute ? Writing an HttpModule [SharePoint2010] and trying to access current web ID using this line of code : private ...
4 votes
1 answer
5k views

Is it possible to copy SP Web from 2010 to 2013?

All I am trying to do is copy a SharePoint Web (i.e: http://sp2010/hr) to (i.e: http://sp2013/hr). I was able to export using: Export-SPWeb http://sp2010/hr –Path "hrexport.cmp" But when I try to ...
1 vote
1 answer
583 views

Group cannot be found

I am getting error Group cannot be found when I use following code: string group = GetGroupName("1"); SPUser user = web.SiteGroups[group].Users.GetByID(SPContext.Current.Web.CurrentUser.ID); But ...
0 votes
1 answer
462 views

SP16 - Change Web top navigation with PowerShell

I want to change navigation in my website with powershell This is my code: function SettingUpNavigation($webURL){ $spWeb = Get-SPWeb -Identity $webURL $SPPubWeb = [Microsoft.SharePoint....
0 votes
1 answer
32 views

Page title cannot be set

Cannot set programmatically the title of my SP page - i mean to the SPWeb object: web.Title = "..."; web.Update(); The changes are set only after one more refresh of the page. But i need the correct ...
0 votes
2 answers
908 views

SPContext.Current is null while calling SPContext.Current.Web.EnsureUser() method

SPContext.Current is null while calling SPContext.Current.Web.EnsureUser() method. Any suggestions?
1 vote
1 answer
605 views

Empty properties? when I call $web.GetFile() method from Powershell

I wonder why when I execute this two lines $wpDestinationPageFullUrl = "http://root/sites/SitioModelo/TestLoadWebPart/SitePages/HomeTest.aspx" $siteUrl = "http://root/sites/SitioModelo/...
1 vote
2 answers
431 views

How to check if a subweb exists within a web

How can i check if a subweb exists among SPWeb.Webs ? If i try web.Webs["SubWeb"] it will rise an exception. Is the following solution clean ? SPWeb webfound= null; foreach (SPWeb subweb in ...
0 votes
1 answer
12k 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 ...
3 votes
2 answers
4k views

Get all groups for a specific web site (NOT SITE COLLECTION) using powershell?

I would like to know how to get all groups of a specific web site using powershell. I do know that all groups are defined at the site collection level but when browsing in a specific web, it only ...
0 votes
1 answer
2k views

Modifying a list item field using powershell without changing the following values (modifed/modifiedby/Version)

I have a list which contain the built-in Description field (internal name = comment) which is if type "Rich Text",now i have created a new site column of type "Enhanced Rich Text" named "Custom ...
0 votes
1 answer
32 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(...
2 votes
2 answers
763 views

Why SPWeb.Group provide a method named Add() that always raises exceptions (that we can not use)

I have the following inside my c# console application using (SPSite site = new SPSite(scurl)) //site collection url { using (SPWeb web = site.OpenWeb(subsiteurl0)) //specific subsite url ...
0 votes
2 answers
106 views

Open web in privileges mode and use it outside

I'm often using pattern where I create class Workspace. This class has some basic functionality and on of them is opening of webs, and also web in privilege mode: public class Workspace : IDisposable ...
3 votes
3 answers
19k views

How to get specific sub sites Using Get-SPWeb object

In the code below i only want to get following 3 specific subsites using Get-SPWeb Object. which filter command is most appropriate to target only these 3 sites 1. http://myCo.root.site/sites/News/...
3 votes
1 answer
196 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 ...
0 votes
4 answers
662 views

Space in URL causes fail in get-spweb?

The issue - I have a number of SP 2010 webs under a main address, as in http://mysite/webname1 http://mysite/webname2 http://mysite/web name 1 http://mysite/web name 2 Doing a Get-SPWeb for the ...
4 votes
3 answers
318 views

How to get the value of list count in SPWeb level?

Hi i`m making a Windows application that analyse the SharePoint Site. In SPWeb level, I want to get the value of list count. I tried to like this SPWeb.Lists.Count.ToString(); But when I compare ...
0 votes
3 answers
231 views

Determine path to site from a given URL

Suppose I have the URL to a file. How can I determine the path to the (sub)site (spweb) it is hosted on, using JavaScript. Here are some examples. Bolded text is what I am looking for: https://...
1 vote
1 answer
775 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/...
7 votes
4 answers
516 views

How can I count Document library in Sites(SPWeb) Level?

I`m making SharePoint site Analysis program. And I have a question. In Sites(SPWeb) Level, I want to count document library. So I`m using SPWeb.DocTemplate Property like this. public class ...
3 votes
1 answer
281 views

cant find /_layouts/AreaTemplateSettings.aspx

I try to save my spweb as template but i dont have this page on my site how can I get it , even my web is a publishing site) my template site is :CMSPUBLISHING #39
2 votes
1 answer
704 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 ...
0 votes
1 answer
217 views

SPListTemplateType.DocumentLibrary cannot be used to create a library

I want to create a new Document Library using server side code and I try to use SPListTemplateType.DocumentLibrary inside SPWeb.Lists.Add() method but it won't allow me. I have to used ...
4 votes
4 answers
160 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 ...
1 vote
2 answers
5k views

Import-SPWeb error: "The file xxx.cmp does not exist."

I have a strange issue with Export-SPWeb and Import-SPWeb for SharePoint 2013. I want to export one of my sites, so I type this command: Export-SPWeb https://test.mywebsite.com/site -Path "export....
5 votes
4 answers
13k views

How can I get a reference to a specifc SPWeb object in a custom timer job?

I have a custom timer job that imports data from an external source into a specific list on a specific Web in my SharePoint 2010 installation. That is the job is only relevant to one list on one web. ...
5 votes
2 answers
9k views

Using SPContext.Current to get public URL of the current zone

I have a single content Web application in the Default zone of my MOSS 2007 farm, which I then extended to the Extranet zone. The default zone web application uses Windows authentication and standard ...
0 votes
1 answer
1k views

Import-SPWeb Into Host Named Site Collection

I have made a backup of a SharePoint Site using Export-SPWeb. I have also added a new Host Named Site Collection and I would like to Import the Site into this newly created Host Named Site Collection. ...
2 votes
1 answer
2k views

What is the SPWeb.Name property for?

I'm wondering what use does the SPWeb.Name property have. Is it displayed anywhere?
2 votes
2 answers
354 views

SPWeb.Exists returns true for web don't exists

Below snippet returns true for invalid web URL: using (SPSite site = new SPSite(url)) { using (SPWeb web = site.OpenWeb()) { return web.Exists; } } Web was created and deleted ...
1 vote
2 answers
828 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
1 answer
179 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 ...
1 vote
0 answers
141 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 ...
1 vote
1 answer
184 views

Detecting change in users/groups on web

I want to execute some code when the users/groups with access to a web changes (addition and removal of users/groups). What are my options?
0 votes
0 answers
218 views

How to tell if a person has modified any content on a SharePoint site programmatically?

We need to find out if a disgrunted employee has modified any content on any number of many SharePoint sites we have. Aside from how we are currently reviewing lists by modified date manually (...