spsite

Best Pattern for AllowUnsafeUpdates

So far, in my research I have seen that it is unwise to set AllowUnsafeUpdates on GET request operation to avoid cross site scripting. But, if it is required to allow this, what is the proper way to handle the situation to mitigate any exposure? Here is my best first guess on a reliable pattern if you absolutely need to allow web or si...

Programmatically Accessing SharePoint Style Library from within C#

Hi all 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 stored in a subdirectory of 'Style Library' from within the new website but how can I...

How do I open search center web for a given site

I can determine the search center page for a site using: site.OpenWeb().AllProperties["SRCH_ENH_FTR_URL"] If I have multiple sites in a web application say site1 and site2. site1 has searchcenter page. site2 does not have one. But for site 2 if i put /SearchCenter/Pages for the search center. It uses the site1's search center. Howev...

Sharepoint SPSite

I am trying to create a spsite of object for sharepoint search but i am getting exception in production as website not found SPSite site = new SPSite("sitename"); ServerContext scon = ServerContext.GetContext(site); SearchContext srchcontext = SearchContext.GetContext(scon); Scopes sc = new Scopes(srchcontext); ...

Issus deleting a site collection

Hi, I'm currently doing some test where I try to delete a site collection programmatically. Thereby I realized some strange behavior by SharePoint. I used the following code to test the site collection deletion. private static void DeleteSiteCollection(string urlSiteToDelete) { SPSecurity.RunWithElevatedPrivileges(delegate() ...

How do I specify the encoding of an SPSS syntax file?

I am writing out statistical results in SPSS with code like OMS / SELECT Tables Headings / DESTINATION FORMAT = OXML OUTFILE='C:\Temp\outfile.xml'. The syntax file is saved as UTF-8 (with bookmark). It has some words with umlauts (german funny characters like ä, ö, ü). When I open the syntax file, it displays these umlauts as Ã...

SharePoint SPSite Disposing

The scenario I have, is in the Execute method of a SPJobDefinition I want to go through every SPSite in the web application. So I have the following code: foreach (SPSite site in this.WebApplication.Sites) { ... } Question is, do I need to dispose of each site? The rule I normally go by is dispose or put inside a using only if I new...

why my sharepoint workflow always stop when i use this code ?

I need to find an user in a list to set the assignedto task property, these informations are in a list. So i use this method : public static SPUser GetSPUser(SPListItem item, string key){ SPFieldUser field = item.Fields[key] as SPFieldUser; if (field != null) { SPFieldUserValue fieldValue = field.GetFieldValue(ite...

SPSite Directory Selection (C#)

I have a code that is running through all the Sites that we have created in SharePoint and finding the Sites that have documentation. When I create the SPSite object (?), I am defining a specific directory, but no matter what I seem to do, the script always runs through all the Sites in SharePoint, not just the sites in the specified dir...

Drop pdf file to sharepoint in asp.net

Hi guys, what's the best way to accomplish this task? (new to sharepoint) Do we need to install sharepoint on webserver in order to use sharepoint.dll/spsite object or just adding the reference to sharepoint.dll in asp.net is sufficient ? If yes then what features of sharepoint need to be installed? TIA ...

How do we export SPSite in SharePoint by C# ?

Hi all , I have a trouble with export SPSite. My site : http://prog-phongdang , I want to export this site to the folder C:/Export which this folder contains onet.xml and some other files of this site. Please help me ! Thanks, Phong Dang ...

Create mysite of User programatically

if user's mysite is not created, it needs to be created to add list. So how to check if mysite is existing or not and to create if not created. ...

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

Hi, 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 custom webpart like B. Thanks in advance for help! ...

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 telling me the contents are blocked. So I want to handle this more gracefully by checking whe...

SPSite contructor returns cached instance.

Using the SPSite contructor (new SPSite(mySiteId)) returns a cached entry, even though site no longer exists. How can I prevent this? ...

Is possible to inherit from SPWeb?

Hi, Is possible to inherit from SharePoint classes such like: SPWeb, SPList etc. or this classes are sealed? I couldn't find right answer. Chris ...