Tuesday, May 15, 2012

Few SharePoint interview Questions


What is difference between list definition and list instance?

List Definition and List Instance are two different concepts.

List definitions are the templates for creating the list. List definition includes the schema for the list. I.e. what are fields in list, whether content type is associated or not, Views in list etc. We created ListDefinition means does not the actual list exist but the template for creating the list is available.

ListInstance is the actual a list. In which we need to specify the templateid of the ListDefinition. From one ListDefinition we can create multiple List instances. 


So ListDefiniton is used when we need to create similar list on different webs.

What are the three user authentication methods that SharePoint 2013 supports?


Windows claims

Security Assertion Markup Language (SAML)-based claims
Forms-based authentication claims


Is Visual Upgrade available in SharePoint 2013?

No.

How would you handle a bulk upload?

What are some of the key differences between SharePoint 2007 and 2010?
Service Applications
Business Connectivity Services
Claims Based Authentication
Sandboxed Solutions
Developer Dashboard
Throttling and List Controls

What’s new with Visual WebPart in SharePoint 2013?
A new Visual WebPart Template has been added to Visual Studio 2012 for Creating Visual Webparts for SharePoint 2013. In this new Template both the User Control and WebPart Classes are merged to Create one template unlike SharePoint 2010 where you had a separate ascx and webpart file.Also, now you can Create both Sandbox and Farm solutions using Visual WebPart Template.

Can we deploy Solutions Created in SharePoint 2010 in SharePoint 2013?
Yes. Most of the Solutions Should work fine but it is Recommended to Re-Create a Solution in Visual Studio 2012, Re-add all the features,Components and then deploy it to SharePoint 2013.

Why Would you Recommend Re-Creating Solutions?
SharePoint 2013 provides Support for both 14 Hive and 15 Hive.Both the directories are Created by default.So if you deploy a SharePoint 2010 Solution that refers to say _layouts folder, the reference will be made to 14 Hive and not 15 Hive by default. To make the solution refer to 15 Hive’s _layouts folder you need to Re-Create the Solution in Visual Studio 2012 and fix the _layouts reference to add ’15′ into it.
e.g.
14 Hive – _/layouts/custompage.aspx
15 Hive – _/layouts/15/custompage.aspx

How do you Force a Solution to be Deployed to 15 Hive and not 14 Hive?
If the solution was Created in Visual Studio 2010, you would add SharePointVersion=”15.0″ attribute in Solution’s manifest.xml file to force it to deploy in 15 Hive instead of 14 Hive.If the Solution however is Created in Visual Studio 2012, you don’t need to do anything, it gets deployed to 15 Hive by default.

How do you Deploy Solution to 14 hive or 15 Hive without modifying Solution.
In SharePoint 2013 with the new “CompatabilityLevel” parameter of Install-SPSolution cmdlet you can now Deploy your wsp Solutions to 14 hive, 15 hive or both.

Are there any Changes to Solutions deployed in \bin directory and GAC in SharePoint 2013?
You can no longer add partial trust Solution Packages to the \bin directory.Any files deployed to the \bin directory must be full trust. Any deployment scripts needs to be updated to make sure that they specify the correct trust level. After the release of .NET Framework 4.0, the GAC was split into two, one for each CLR.
c:\windows\assembly is the location for .NET versions 1.0 through 3.5 and c:\windows\microsoft.net\assembly is location for all the dlls for project Created in .NET Framework 4.0.

How would you a Migrate a Site Collection in SharePoint 2013?
1. Backup and Restore SharePoint 2010 Content database in your SharePoint 2013 farm.
2. Run Test-SPContentDatabase cmdlet to identify missing Components along with potential errors and related warnings. Check the upgrade log and deploy any missing components and re-run the cmdlet to verify.
3. Attach the Content database to the desired web application using Mount-SPContentDatabase cmdlet.
4. After successfully mounting the content database to web application, the site should be accessible in 14 mode.
5. Next, to Upgrade the site to 15 Hive, Navigate to SiteUpgrade.aspx page in Site Setting of your site collection.
6. Click on “Upgrade the Site Collection” button.
7. During the upgrade The SiteUpgrade.aspx page shows the progress and provides a link to an upgrade log for troubleshooting purposes.
8. Site Collection Should now be accessible in 15 mode.

What do you mean by WSP?

- WSP stands for Web Solution Package. It is a cabinet file that contains assemblies, resource files, features, images, application pages, site definitions etc. into single file.
- Whenever any customization or upgradation or updation is carried out in SharePoint, various items like assemblies, resource files, features, images, application pages, site definitions etc. are required to deployed.
- It becomes difficult to deploy these items separately in development, staging and production. This called for a powerful deployment tool in the form of WSP.

What is the difference between backing up a Site Collection and exporting a Site Collection?

Backup a site collection:
Backup-SPSite -Identity -Path [Force] [-NoSiteLock] [-UseSqlSnapshot] [-Verbose]

Export a site collection:
Export-SPWeb -Identity -Path [-ItemUrl ] [-IncludeUserSecurity] [-IncludeVersions] [-NoFileCompression] [-GradualDelete] [-Verbose]

Point 1:
Backup-SPSite is generally used when you want to replicate the entire site collection (including all subsites) to an existing web application.

Export-SPWeb is generally used when you want to replicate just a single subsite to an existing site collection.

Point 2:
Workflows are included when you use the Backup-SPSite.

Export-SPWeb, It does not preserves workflows instances, associations, history and tasks. Every workflow association must be recreated and there is no way to restore the running instances from original site.

Note: if you're working in single environment (or cloned environment) backup & restore will do the trick. If you need to move site collection between environments, export & import are better suited.

What are the types of input forms that can be created for a workflow ?

You can create four different types of input forms including
1. An association form
2. An initiation form
3. A modification form
4. A task edit form.

If you were asked to create a custom workflow for SharePoint 2010, what development tool would you use?

This depends on the workflow. Factors such as whether it needs to be installed in multiple locations, how it steps through stages and the complexity all determine the tool to use. The most likely tool will either be SharePoint Designer or Visual Studio.

How would you integrate a non-Microsoft SQL database with SharePoint 2010?

I would use SharePoint Business Connectivity Services (BCS) and a custom Web service. I would develop a custom Web service on the Microsoft model that was connected to the data sources. Then I would connect this Web service to SharePoint via BCS.

You’re developing a custom SharePoint 2010 solution. The solution writes data to a SharePoint list that users may or may not have access to. How would you assure that the application would always work and not throw an error?
Depending on the situation, I would either access the list having invoked RunWithElevatedPrivileges, or by establishing a SPUserToken to give my code the access it needs, while keeping SharePoint security unaffected.

What is a SPSite and SPWeb object, and what is the difference between each of the objects?  


The SPSite object represents a collection of sites (site collection [a top level sites and all its subsites]). The SPWeb object represents an instance SharePoint Web, and SPWeb object contains things like the actual content. A SPSite object contains the various subsites and the information regarding them. 



When should you dispose SPWeb and SPSite objects? And even more important, when not?

You should always dispose them if you created them yourself, but not otherwise. You should never dispose SPContext.Current.Web/Site and you should normally not dispose SPWeb if IsRootWeb is true.



What is a SharePoint Feature? What files are used to define a feature?

SharePoint Feature is a functional component that can be activated and deactivate at various scopes throughout a SharePoint instances, such as at the farm, site collection, web, etc.


How would you go about getting a reference to a site? 

C#: 

oSPSite = new SPSite("http:/server");
oSPWeb = oSPSite.OpenWeb(); 

What does a SPWebApplication object represent?


The SPWebApplication objects represents a SharePoint Web Application, which essentially is an IIS virtual server. Using the class you can instigate high level operations, such as getting all the features of an entire Web Application instance, or doing high level creation operations like creating new Web Applications through code


Would you use SPWebApplication to get information like the SMTP address of the SharePoint site? 

Yes, since this is a Web Application level setting. You would iterate through each SPWebApplication in the SPWebApplication collection, and then use the appropriate property calls (OutboundMailServiceInstance) in order to return settings regarding the mail service such as the SMTP address.

Difference between Team Site and Publishing Site?



Team Site:


This is one of the simplest site template which is helpful for a group of people to work together and share information and ideas. It has some list templates like announcement, task list, Links list etc.

This template mostly used in intranet applications like employee portals.

Publishing Site:


Publishing site templates are widely used in Internet facing web sites. As then name suggest we need to publish the page whenever we do modifications so that it will appear to other users. Publishing Site templates meant for Web Content Management (WCM).


There are few more features than team site.


The publishing feature includes a publishing approval workflow to help ensure that the information shared is reviewed for quality and correctness.


Publishing pages have page layouts that can be changed on the fly, and custom page layouts can be created using SharePoint Designer in order to offer a very customized means of laying out information for users. Page layouts also provide a means for standardizing the layout of information. The use of page layouts in particular is a primary reason content managers will enable the publishing feature in a collaborative site.


A Publishing site is setup so that anonymous users cannot access the “backstage” part of SharePoint (like the “View All Site Content” page).

Use a Publishing site when you want to have a public facing site or an extranet that is exposed to the internet.

Use a Team site with Publishing enabled, when you want to keep things internal, but have more options for customizing you’re branding of your intranet.


Even if in Team site you can also activate the publishing features. Activating the SharePoint Server Publishing Infrastructure feature adds the Administrative links on the Site Settings page, including the ability to manage Master Pages for both publishing and non-publishing Web sites, Navigation, Searchable columns, Content and Structure, Content and Structure Logs, Variations and Translatable columns.


To enable publishing on a team site go to Site Actions > Site Settings > Site Actions > Manage site features and select Activate SharePoint Server Publishing.



How do you connect (reference) to a SharePoint list, and how do you insert a new List Item?

C#: 

using(SPSite mySite = new SPSite("yourserver"))
{
using(SPWeb myWeb = mySite.OpenWeb())
{
SPList interviewList = myWeb.Lists["listtoinsert"];
SPListItem newItem = interviewList.Items.Add();
newItem["interview"] = "interview";
newItem.Update();
}
}


 What is Content Type?

A content type is a flexible and reusable WSS type definition that defines the columns and behavior for an item in a list or a document in a document library.
You can also add existing list columns to the list content types on the list. Also when you add columns directly to a list, and that list contains multiple content types, you can specify whether you want the new column to be referenced in all the content types on that list.


What is the difference between Site Pages Vs Application Pages?


Site Pages 


1. Site pages are pages that are created, edited, and customized by end users. 

2. They are primarily used for the content in a site. Site pages come in two types—a standard page and a Web Parts page. A standard page contains text, images, Web Parts, and other elements. A Web Parts page contains Web Parts in Web Part zones. They have a predefined layout that uses Web Part zones. Both types of site pages are edited using a Web browser or Microsoft SharePoint Designer.

3. Site pages are provisioned from a template page that is stored on the file system of the front-end Web server. When a site is provisioned, SharePoint Foundation creates a pointer to the instance of the page template on the file system. This allows SharePoint Foundation to avoid repeatedly creating copies of the pages, which are provisioned each time a site is created.


When a user customizes a site page, the template for the page is then stored in the content database. The page is retrieved from the content database every time it is requested by a user. A customized page can, however, be reset to the original template page through the Web browser or a tool such as SharePoint Designer.


4. Site Pages allow customization (which can be open SPD and modify),Customized site pages cannot contain in-line server code. 


The following are general rules for using server-side code on a site page.


a. If the page is uncustomized, server-side code is supported on the page.


b. If the page is customized, server-side code does not run, and the page does not render. 


5. They are slower as compared to Application pages as they are parsed everytime they are accessed

6. Site Pages do not allow in-line code (To allow in-line code we need to change web.config at  "<PageParserPaths> <PageParserPath VirtualPath="/_mpg/*" CompilationMode="Always" AllowServerSideScript="true" IncludeSubFolders="true"/>  </PageParserPaths>
Pages stored in pages libraries or document libraries or at root level within SharePoint are Site pages like webpart page, wiki pages..

Examples of site pages include the home page (default.aspx) for a site as well as the pages associated with lists and document libraries, such as AllItems.aspx, NewForm.aspx, and EditForm.aspx.  


Application Pages 


1. These are the normal .aspx pages deployed within SharePoint. Most Common of them are the Pages which are used in central admin.

2. Application Pages are located in _layouts folder under 14 hive (FileSystem @ " %ProgramFiles%\Common Files\Microsoft Shared\web server extensions\14\TEMPLATE\LAYOUTS " )
3. Site Pages not allow customization.
4. Application pages are compiled once, They are much faster.
5. Application pages allow in-line code (writing server side code in .aspx
These are the normal .aspx pages deployed within SharePoint. Most Common of them are the Pages which are used in central admin.
6. They cannot use dynamic Web Parts or Web Part zones or be modified using SharePoint Designer. 

why sitepage dont allow inline code?


Because when a page is site page and not yet customized, (the page is still pulled from the file on the file system instead of the database) SharePoint Server allows the page to run normally. However, if you customize the page by using a tool such as Microsoft Office SharePoint Designer 2010, the page is run through the safe mode parser in SharePoint Server, which blocks any inline code from running.

Difference between SPSite and SPWeb?

SPSite represents the top level site or the collection of sites

SPWeb represents the instance of a site, SPWeb contains all the content of a site.

See the below example:

SPSite MySiteCollection = new SPSite(http://servername/);

SPWeb MyWeb = MySiteCollection.AllWebs("Site Name");

Difference between Solution and Feature?

Feature is module that allows you to add new abilities to your SP site.
Solution is a set of files (including features files) that helps you to deploy features to your SP server..
Difference between Master page and Page Layout?

Page layout defines the structure of the page. Also defines rendering of content types.


Master page contains the overall appearance and branding of the site. Master page contains elements like stylesheets, common search webpart, navigation components, header and footer etc.


Pagelayout and master page are merged runtime to generate the complete page.



Differences are

1) Master pages contain controls that are shared across multiple page layouts,
such as navigation,search, or language-preference for multilingual sites.
Page layouts contain field controls and Web Parts.

2) Page layouts can be used by all page instances that are based on that

page layout.Master pages can be used by all page instances in a site.


What does a SPWebApplication object represent?


The SPWebApplication objects represents a SharePoint Web Application, which essentially is an IIS virtual server. Using the class you can instigate high level operations, such as getting all the features of an entire Web Application instance, or doing high level creation operations like creating new Web Applications through code.



SharePoint Web Parts Vs ASP.NET Web Parts?



ASP.NET Web Parts:

  1. These Web Parts are built on top of the ASP.NET Web Part infrastructure. The ASP.NET-style Web Parts have a dependency on System.Web.dll and must inherit from the WebPart base class in the System.Web.UI.WebControls.WebParts namespace.
  2. These Web Parts can be used in ASP.NET applications as well as in SharePoint Foundation, making them highly reusable.
SharePoint-based Web Parts:
  1. These Web Parts have a dependency on Microsoft.SharePoint.dll and must inherit from the WebPart base class in the Microsoft.SharePoint.WebPartPages namespace.
  2. These Web Parts can only be used in SharePoint Web sites.
What is the difference between internet site and intranet site?

An internet site is a normal site that anyone on the internet can access ( http://ukreddysharepoint2010.blogspot.in/ , www.microsoft.com etc ). The internet site is used for public presence.

An intranet site though hosted on a web site, can only be accessed by  people who are members of a specific network. They need to have a login and password that was assigned to them when they were added to the site by the site administrator. The intranet is commonly used as  an internal tool for giving employees access to company information.

What is SPSecurity.RunWithElevatedPrivileges?

Its delegate method that is to run with elevated rights. This method runs under the Application Pool identity, which has site collection administrator privileges on all site collections hosted by that application pool. 

or


RunWithElevatedPrivileges create a new thread with the application pool's credentials, blocking your current thread until it finishes.



What is the performance impact of RunWithElevatedPrivileges?


RunWithElevatedPrivileges creates a new thread with the App Pool's credentials, blocking your current thread until it finishes.


What is the internal name of the Created By field in list?

Author  ex: find here

What is the internal name of the Modified By field in list?

Editor  ex: find here

What is web.allowunsafeupdates?


If your code modifies Windows SharePoint Services data in some way, you may need to allow unsafe updates on the Web site, without requiring a security validation. You can do by setting the AllowUnsafeUpdates property.


C#:

using(SPSite mySite = new SPSite("yourserver"))
{
using(SPWeb myWeb = mySite.OpenWeb())
{
myWeb.AllowUnsafeUpdates = true;
SPList interviewList = myWeb.Lists["listtoinsert"];
SPListItem newItem = interviewList.Items.Add();

newItem["interview"] = "interview";

newItem.Update();
myWeb.AllowUnsafeUpdates=false;
}
}

The Microsoft idea behind introducing the AllowUnsafeUpdates property is to protect YOU from cross-site scripting attacks. The way this works is that if your application is running in an HTTPContext (i.e. it’s a web part for instance) and the request is a GET request then SharePoint will refuse to do any changes unless the value of AllowUnsafeUpdates is set to true and by default it will be false for GET requests. If you try to do any updates to lists, webs or any SharePoint objects that require an SPSite to be created first, and if you don’t set AllowUnsafeUpdates to true you will get this exception:

"System.Exception: Microsoft.SharePoint.SPException: The security validation for this page is invalid. Click Back in your Web browser, refresh the page, and try your operation again. —> System.Runtime.InteropServices.COMException (0x8102006D): The security validation for this page is invalid. Click Back in your Web browser, refresh the page, and try your operation again."

what is the purpose of calling clientContext.ExecuteQuery()?


ExecuteQuery will minimize the number of rountrips to the server from your client code. All the Components loaded into the clientCotext are executed in one go.So the it will increase performance of the application.


Can you develop webparts and other SharePoint solutions at your local machine?


in order to run and debug SharePoint solutions, the project must reside on the server which has windows SharePoint service installed. however, you can reference the Microsoft.SharePoint dll in your project at your local, but you will not be able to run it.


What are the differences between site definition and site template?



Site Templates : Are  snapshots of  sites at a point in time. When a user customizes a site from the UI or SPD, the custom template consists of the difference between the original state of the site (determined by its definition) and the state of the site or list when the custom template is generated.
Custom templates remain tied to a particular site definition (for example, the site definition for SharePoint Web sites or Meeting Workspace Web sites), so that if the site definition is not present or is changed, the custom template cannot work.

Site Definitions : As the name implies, A Site definition is "core definition of a site" . Each site definition emerges through a combination of files that are placed in the 14 hive of WFE during installation of SharePoint. Site definition files include .xml, .aspx, .ascx, and .master page files, as well as document template files (.dot, .htm, and so on), and content files (.gif, .doc, and so on).




Site Definitions
Files are on disk, better performance.
Highly customizable and extensible (XML  and .NET code is much more flexible than UI)
Can provision multiple webs *
Complex to create
Requires admin access to server for deploying.
Modifying the site definition after provisioning at least one site from it is not supported and might break existing sites.
Site Templates
Files are in database, less efficient.
Not easily extensible  (You are limited by what UI offers)
Can only provision one web
Easier to create
Installable from a Web UI by site owners.
Custom templates can be modified without affecting existing sites that have been created from the templates(**).
* This could be achieved using Provisioning handler ( For more info, refer to the Publishing Site Definition in the 14 hive )

** Please note that If the site definition on which the custom template is based does not exist on the WFE, the custom template does not work.



On the surface, it appears that a site template has numerous advantages; it is certainly easier to create and deploy, and you can change it without breaking sites that use earlier versions of the template because it is not centralized in the 14 hive.


However, the fact that a site template contains everything about a site in a single file makes granular modifications of individual elements very difficult. For many projects, that is a good enough reason to suffer the additional complexity of site definitions.


However, site definitions present a different challenge. If you change an existing site definition in the 12 hive, you run the risk of breaking any sites that were created previously and use the existing definition. ( Besides, this is not supported by Microsoft ) , The key is to adopt the same strategy as for the core WSS site definitions:

Keep the definition as simple as possible and use feature stapling for everything else. Feature stapling allows you to add a feature to an already existing site definition. You may think this would be a complete waste of time, because you can simply add the feature into the site definition using far less code than having a feature staple, but when I tell you that
Microsoft does not support modifying a site definition in any way after a single site has been provisioned from that site template, you may reconsider.

Features are not an alternative to site definitions. Features are a complement to site definitions. If you keep the site definition as simple as possible and use features for the majority of a site elements, you gain the benefits of granular control in the development environment while reducing the risks involved in making changes to production systems over the life of the sites.




When should you dispose SPWeb and SPSite objects? And even more important, when not?
You should always dispose them if you created them yourself, but not otherwise. You should never dispose SPContext.Current.Web/Site and you should normally not dispose SPWeb if IsRootWeb is true. More tricky constructs are things along the line of SPList.ParentWeb.

In SharePoint we have one object type that holds references to unmanaged COM components: the SPRequest object. Each SPWeb and SPSite hold a reference to one of these SPRequest objects. So in all custom code using SPWeb or SPSite objects it is vital to correctly dispose these objects to free up no longer required memory resources.





If you have created them in your code, you can dispose them in Finally block or you can use the "using" clause, so that they gets disposed when not required. If you are using SPContext then you need not dispose the SPSite and SPWeb objects
If you have an ItemUpdated or ItemUpdating event receiver and it causes an update to the item, how do you prevent another ItemUpdated and ItemUpdating event from being fired during your update?
Before performing your update, call DisableEventFiring(). After update, call EnableEventFiring().

When modifying a list item, what is the "main" difference between using SPListItem.Update() and SPListItem.SystemUpdate()?


A. Using SystemUpdate() will not create a new version and will also retain timestamps.


What is ONET.xml ?


What is Schema.xml?

Updating....

No comments:

Post a Comment