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

learn more… | top users | synonyms

18
votes
3answers
5k views

Find Document by GUID

I'm missing something that must be so simple that it's not even worth asking... but I have an object ID (GUID)... How do I figure out the document it points to? For example I have a GUID of ...
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 ...
9
votes
4answers
859 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 ...
9
votes
1answer
587 views

Is it necessary to call SPWeb.Update() after setting AllowUnsafeUpdates?

Amidst working on resolving this issue, there's something I was curious about, and something that I've been very inconsistent about in my code. If you enable SPWeb.AllowUnsafeUpdates = true, do you ...
7
votes
3answers
587 views

Should SPWeb objects be passed to other methods or re-instantiated?

Should I pass my SPWeb object to a method or recreate it in that method?
7
votes
4answers
889 views

What are the dangers of using a static class that contains your SPWeb object?

When creating my SharePoint 2010 solutions, I often create a static class that contains helper methods and lists, documents, list items, etc that I use frequently. What would the dangers of putting my ...
7
votes
3answers
3k views

Detected use of SPRequest for previously closed SPWeb object within workflow

I have a visual studio sequential workflow. In that workflow, I have a string property called AllowDisposition. When the workflow starts, I populate that value by doing workflowProperties.Item["FIELD ...
6
votes
3answers
3k views

Disposal of SPWebs retrieved from SPContext.Current.Site.AllWebs

As there was a minor disagreement on whether SPWebs retrieved from SPContext.Current.Site.AllWebs should be disposed, I thought it would be appropriate to post a new question and discuss it here. I ...
6
votes
2answers
2k views

Do I need to reset SPWeb.AllowUnsafeUpdates after use?

Do I need to reset the SPWeb.AllowUnsafeUpdates property after use? Seems not, but all over the web there is code like: bool allowUnsafeOrig = web.AllowUnsafeUpdates; web.AllowUnsafeUpdates = true; ...
5
votes
3answers
5k views

How to run with elevated privileges in application page?

I want to get a list item that the current user does not have access to but I need to get it in code. When I use SPSecurity.RunWithElevatedPrivileges that does not work. It's because I'm using the ...
5
votes
3answers
2k views

Should I dispose SPWeb or SPList?

I am doing a whole bunch of things with one SPWeb and many SPLists. If I just dispose web in the finally section would that dispose all of SPLists that I instantiated? (btw, I understand the concept ...
5
votes
4answers
8k 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
2answers
1k views

Will passing SPWeb as by value parameter cause a memory leak?

I have an issue in my SharePoint environment and I suspect that this code causes a memory leak. I'm passing a SPWeb object as a value parameter. Will the SPWeb object instance get disposed correctly ...
5
votes
1answer
75 views

How can i get name of the site definition configuration or site template from SPWeb?

I know that SPWeb have "WebTemplate" property and it always gives me string like "STS" or "MPS", but what I need is something like "STS#1". There is also "WebTemplateId" property, it gives WebTemplate ...
4
votes
1answer
854 views

Is accessing AllProperties efficient?

I'm currently storing a few values in the SPWeb.AllProperties hashtable. But I'm thinking of adding even more data into it. Before I start using it more and more though, I wondered if using ...
4
votes
5answers
3k 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, ...
4
votes
2answers
3k views

How to access a file in the current url or _layouts folder?

My code behind code from the aspx webpage uses a transform.xsl to do some custom xslt transformation. Scenario 1: Try to get the file from the _layouts folder. SPWeb web = SPContext.Current.Web; ...
4
votes
2answers
7k 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 ...
4
votes
3answers
105 views

best way to store property of a site

I have a site called Exhibitions that contains many many subsites each of which is an individual exhibition (with pages, images etc). I would like to attach to each of these subsites a property which ...
4
votes
1answer
2k 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 ...
3
votes
4answers
2k views

How to properly use the Using Statement with SharePoint Objects

What is best practice with the Using statement when working with SharePoint Objects. When and how should you use the Using statement, so objects used are disposed, etc?
3
votes
2answers
207 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 ...
3
votes
4answers
3k views

Get SPWeb by ID without Site Collection?

I have a list of SPWeb IDs and would like to open the associated SPWeb objects. However, I do not know in which Site Collection they are (I DO know that they are in the current Web Application ...
3
votes
1answer
180 views

Disposing of SPWeb object query

I'm trying to understanding the object clean up process. using (SPSite siteCollection = new SPSite(siteUrl)) { SPWeb site = siteCollection.RootWeb; foreach (SPList list in site.Lists) { if ...
3
votes
3answers
1k views

How to create Site (SPWeb) on Sharepoint Online

I have a problem creating Sites on Sharepoint Online. The code that works on-premise do not work on Sharepoint Online. I do not want to bother you with the code, i just want a clean start. So my ...
3
votes
1answer
2k views

System.InvalidOperationException: Operation is not valid due to the current state of the object

This error happens on every page of the site. I click on link to open page like http://myportal.com/Lists/List1/ SharePoint open it and in url add smth like AllItems.aspx, so it url looks like ...
2
votes
4answers
580 views

What are the dangers of disposing of SPWeb when it's automatically disposed of?

In some cases such as: using (SPSite site = new SPSite(@"http://sitecollection/")) { SPWeb web = site.RootWeb; } you don't need to dispose of the SPWeb object because it is disposed of ...
2
votes
2answers
4k 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 ...
2
votes
4answers
2k views

SharePoint 2010 - Add WebPart to a Web with PowerShell

I want to add a webpart to a great number of existing pages. Is there any PowerShell command to add a webpart to a webpart page?
2
votes
1answer
1k 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
2answers
464 views

SPWeb.ParserEnabled

What does the SPWeb.ParserEnabled property do? I had a problem for some document which are not able to update metadata.If i use ParserEnabled = false.it is working fine for me. if i use ...
2
votes
3answers
2k views

List of all users having access to at least one site in the site collection

I want to retrieve all the users who are having any access to at least one site in a site collection. I tried using 'SPWeb.SiteUsers' and it gave me almost what i wanted. The only exception was - it ...
2
votes
1answer
913 views

Disposing of objects in an Event Receiver

I have an ItemUpdated event receiver running on a library. Some pretty basic logic. Here's the gist of what I'm doing: SPWeb web = properties.Web; SPContentTypeId ParentCT_Id = ...
2
votes
1answer
2k views

SPWeb.CurrentUser gives wrong result when called from HttpModule

I am trying to get the current logged-in SharePoint username through SPWeb.CurrentUser. This usually provides the results I am expecting, except in one instance. I am logged into my development ...
2
votes
1answer
132 views

What is the effect of setting SPWeb.AssociatedOwner/Member/VisitorGroup

I would like to know the effect of setting/changing the value of the SPWeb properties AssociatedOwnerGroup, AssociatedMemberGroup, and AssociatedVisitorGroup - the only effect I can glean is that it ...
2
votes
2answers
524 views

SPSite.RootWeb.AllProperties is null Claims Authentication

I just created a new WebApplication & Site Collection in sharepoint. Note : WebApplication uses Claims Authentication mode, Custom Trusted Identity Provider for my application. In powershell ...
2
votes
1answer
1k views

Adding SPListItem using SPWeb.ProcessBatchData method

I am looking for adding SPListItem using SPWeb.ProcessBatchData method. Could any one please help me on syntax for adding list item to my custom list.
2
votes
3answers
829 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 ...
2
votes
2answers
706 views

What tool to use to check memory leaks in SharePoint

Currently I encounter memory leaks in my SharePoint 2007 application. What is the best tool to identify is there any un-dispose objects in the codes? Example like DataTable, SPWeb, or SPList.
1
vote
3answers
85 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 = ...
1
vote
3answers
1k views

Storing custom properties for a SharePoint Site

Let's say you are building a Project Management solution where each Project equals one site (SPWeb object). Each project has it's properties like: Project Manager, Budget, Customer, Description, ...
1
vote
1answer
624 views

Memory Leak - Disposing SPSite and SPWeb?

So I read through another post here http://www.sharepointoverflow.com/questions/1047/disposal-of-spwebs-created-using-spsite-openweb. Currently I only dispose of the SPSite object, and from my ...
1
vote
2answers
2k views

Get file from any library in the web tree

Is it possible to use some built in SharePoint API to open a file no matter which web and library it's in? Example: Given the file: /subsiteA/PublishingImages/myimage.jpg I want to open it and get ...
1
vote
1answer
603 views

SPWeb is undefined

I am a newbie in sharepoint and only for 1 month. I am using sharepoint 2007,.aspx. and doing for an email form with some validation, after user pass the validation the email send. But I'm getting the ...
1
vote
1answer
236 views

Error while downloading Lists in a spweb

Here is the code private void downloadList(SPObjectData objectData) { using (SPWeb currentWeb = objectData.Web) { foreach (SPList list in currentWeb.Lists) ...
1
vote
2answers
389 views

Add script reference to all pages in a site collection when a feature is activated

I'd like to have a feature which adds a script reference to all pages in a site collection when activated. This seems like a scenario where I should just modify the master page, but for it to affect ...
1
vote
2answers
123 views

Getting the logged in user given the SPWeb, regardless of elevated priveleges

I have a requirement to be able to always get the logged in user. The object the calling process is going to pass is the spweb. As this is legacy code, I cannot change what the calling processes ...
1
vote
3answers
114 views

How to get all SPWebs using visual studio?

I want to get all webs including it's subwebs. Eg. Site web1 subweb1 subweb2 web2 How to achieve ?
1
vote
1answer
2k views

c# iterating SPWeb.Navigation.GlobalNodes

When I try to iterate through the GlobalNodes collection using c# it is always empty unless I the site and manipulate the navigation settings manually. Can anyone tell me why this is and/or give an ...
1
vote
2answers
1k views

Error using SPRequest when the SPWeb is already disposed

Is this correct way of using the SPSite and SPWeb and the SPList. private SPList list; pulic void getList() { using (SPSite site = SPContext.Current.Web.Site.WebApplication.Sites[0]) { using ...