Friday, April 26, 2013

SharePoint Interview Questions and Answers - Part4

What is the difference between SpSite and SPWeb ?
SPSite is a site collection which can be represented as SPSite class in the object model of SharePoint. The SpSite object is one of the primary entry points to the server object model and will be used frequently in SharePoint application development.
SpWeb is specific site under site collection which can be represented as SpWeb class in the server object model of SharePoint.


What are the classes in Server Object Model?
There are many classes on Server object model, but in development perspective below are some of the classes which are important,

  • SPFarm
  • SPWebApplication
  • SPSite
  • SPWeb
  • SPList
  • SPListItem
  • SPDocumentLibrary
What is Site template? 
By using site templates for SharePoint sites, user can build complete SharePoint applications that can be instantiated over and over again. For example, if user needs a SharePoint site for managing projects including custom lists, Web Parts, and so forth, user can define a site template that user can reuse for every project by instantiating a site from it. A site template provides the basic component and layout of a new site created under SharePoint. A site template contains specific design information about a site, including the list that is part of the site, web part pages used in the site, the site’s themes and borders, changes to the quick launch bar, as well as some site content (such as document libraries)

What is Site definition? 
Site definitions are the collection of XML or ASPX files and can contain all the necessary components. They are packaged in SharePoint solution files (.wsp) and are easy to transport since everything you need is packaged into a single file. Site definition contains information of web parts, lists, libraries, features, and navigation bars to be included in the site.
Site definition contains three files:
• webTemp.xml: Created for every language version and contains the entries for the template selection box on the site creation page.
• onet.xml: Contains one or more configurations for a site template, including specification of all components used, such as features, lists, and Web Parts
• default.aspx: Empty page

What is ONET.xml? 
The core of a site definition is the onet.xml file that specifies all the components that the site contains, such as which Features to load, where the web parts go. ONET.xml file is present in %SharePoint Root% \TEMPLATE\SiteTemplates\XML\Onet.xml location
Note: If site definition is created using the Visual Studio 2010 site definition project template, a basic onet.xml file has been generated automatically. It’s possible to extend this onet.xml.

How to get the data from multiple lists?
Or
What is SPSiteDataQuery class ?
SPSiteDataQuery class is used to retrieve data from multiple lists. Use SPSiteDataQuery object to aggregate data from multiple lists, which obviates the need to enumerate sites and lists.The SPSiteDataQuery class is used to query data from multiple lists across different sites in a site collection. SPSiteDataQuery is commonly used in list aggregation scenarios, where list data from team sites or other subsites is collated and presented in a single interface. Unlike the SPQuery class, you cannot use join predicates or projected fields with the SPSiteDataQuery class. The SPSiteDataQuery will only aggregate data from SharePoint lists and will ignore data from external lists.
Note: It’s not a best practice to use SPSiteDataQuery instead of that make a use of ‘for’ or ‘foreach’ loops to aggregate data.

What is WSP (Web solution package)?
When developer does any customization or enhancement in SharePoint, then there are many items that need to be deployed like assemblies, resource files, features, images, application pages, site definitions etc. It will be a very tedious task to deploy these items separately on development, staging and production. So SharePoint introduced a solution package which is powerful deployment tool. Web solution package is a cabinet file that contains assemblies, resource files, features, images, application pages, site definitions etc. into single file.
Note: A solution package is stored as a cabinet (CAB) file, with the file extension .wsp. This file contains all the files to be deployed. If you rename the file extension to .cab, you can open the solution and explore its content .It can be deployed using the command-line tool stsadm or PowerShell cmdlets.

What is Sandbox solution? 
Before SharePoint 2010, the farm administrator had to trust custom code running on the server which developer had written. That meant having to perform lengthy tests and code reviews before custom code was allowed to run on the server, which cost a lot of time and money. Also there is a risk that if somehow unintentionally the wrong code went onto the server, then there will be chances of performance down issue, server down, crash etc. which is a big risk.
       So by considering all these issues, In SharePoint 2010 there is a concept of sandboxing user code, which allows for isolation and resource limitations regarding memory, CPU, database query count, and time. This means that users can add and consume custom solutions safely without impacting overall farm performance and stability. Sandboxed solutions run with lower trust for hosted environments, for testing foreign solutions, and for secured production servers. A sandboxed solution cannot access the full SharePoint object model; it is limited to a subset of the Microsoft.SharePoint namespace. Sandboxed solutions run in a safe and monitored process with restricted access to resources.

Need more elaboration on Sandbox solution like what are the items deployed under sandbox solutions, restricted areas?
Using a sandboxed solution you can deploy the following SharePoint items:
• Web Parts (code only; not visual Web Parts)
• Event receivers
• Content types
• List templates
• List instances
• Custom actions
• InfoPath forms

Deploying files to disk is not possible in Sandbox solution. This means you can’t deploy the
following SharePoint items:
• Visual Web Parts (they contain web controls that have to be deployed to disk)
• Business data connectivity models
• Application pages
• User controls
• Files included in mapped folders, such as IMAGES or LAYOUTS

The Microsoft SharePoint Foundation Sandboxed code execution host service (SPUserCodeV4) executes the user code (code in your sandboxed solution) in the sandbox.
This service consists of the following three processes:
• Microsoft SharePoint Foundation Sandboxed code execution host service (SPUCHostService.exe)
• Microsoft SharePoint Foundation Sandboxed Code Execution Worker Process (SPUCWorkerProcess.exe)
• Microsoft SharePoint Foundation Sandboxed Code Execution Worker Process Proxy (SPUCWorkerProcessProxy.exe)

What does AllowUnsafeUpdates do? 
For developer, when updates needs to be done in the content database without requiring a security validation then AllowUnsafeUpdates property needs to be set to true. After operation is performed then this property again needs to set to false again.

What is CAML? 
SharePoint has a custom XML language called CAML (Collaborative Application Markup Language), which is used to define key objects such as lists, columns, and content types.

No comments:

Post a Comment