SharePoint Interview Questions and Answers

Below are few SharePoint questions asked in Interview.

Q. Explain Below code

 using (SPSite site = new SPSite(SPContext.Current.Web.Url)) // Gets the absolute url of the website
using (SPWeb web = site.RootWeb) //  Gets the root website of site collection

using (SPWeb web = site.OpenWeb())// OpenWeb accepts either GUId of sites or site url, if parameter is blank means returns the site associated with the current url

SPWeb - Represents SharePoint service websites

SPSite -  Represents a collection of sites in a web application.

SPWebApplication - Represents and IIS web application.

SPWebCollection - Represents a collection of SPWeb object.

SPWebTemplate - Represents a site definition or site template that is used to create SharePoint sites.

SPList - Represents a list on SharePoint Site.

SPListCollection - Represents a collection of SPList object.

SPListItem - Represents a list item or row.

SPListItemCollection - Represents a collection of SPListItem object

Base class for Timer Job - SPJobDefinition
Base class for Event Receiver - SPItemEventReceiver

Q. Write basic code to interact with SharePoint List.
Server Object Model:

   using (SPSite site = new SPSite(SPContext.Current.Web.Url))
                    using (SPWeb web = site.OpenWeb())
SPList list= web.Lists["MyList"]; 
SPListItemCollection items= list.GetItems(); 
web.AllowUnsafeUpdates = true; 
foreach (SPListItem item in items) 
item["Title"] = "New Title";      item.Update(); 
web.AllowUnsafeUpdates = false; 

Client Object Model:

            ClientContext context1 = new ClientContext(Constants.SITE_URL);
            context1.AuthenticationMode = ClientAuthenticationMode.Anonymous;

            List list1 = context1.Web.Lists.GetByTitle("ListName");
            CamlQuery query1 = new CamlQuery();

            query1.ViewXml = @"<Where><IsNotNull><FieldRef Name='Title' /></IsNotNull></Where><OrderBy><FieldRef Name='ID' Ascending='False' /></OrderBy>";

            Microsoft.SharePoint.Client.ListItemCollection listCollection1 = list1.GetItems(query1);
            DataTable dTable1 = new DataTable();

    for (int iCntr1 = 0; iCntr1 < listCollection1.Count; iCntr1++)

                if (listCollection1[iCntr1]["Title"] != null)
dTable1.Rows[dTable1.Rows.Count - 1]["Title"] = listCollection1[iCntr1]["Title"].ToString();


Q. Page Parser Path in SharePoint
There is a limitation in SharePoint, script with runat server code not allowed in Application Pages.
By adding below piece of code it can be done.

<PageParserPath VirtualPath="/myFiles/*" CompilationMode="Always" AllowServerSideScript="true" IncludeSubFolders="true"/>

Now you may add below code to your page:

<script runat="server">
protected void Page_Load(Object sender, EventArgs e)
    Response.Write("Server side code");


Q. Allow unsafe update vs run with elevated privileges
Allow unsafe update is set to true when we are updating content database to avoid external injections.

RWEP - It executes method with full rights even if the user does not otherwise have full control.

{     using (SPSite site = new SPSite(web.Site.ID))     
{     // implementation details omitted    
 } }); 

Q. Safe Control in SharePoint
In sharepoint development environment a developer can add aspx file which may contain affect sharepoint environment, i.e. there might be security risk.
To reduce the rist SharePoint allows to add safe control tag in web.config file to avoid script injection -
<SafeControl Assembly="[Assembly Name]" Namespace="[Namespace]" TypeName="*" Safe="True" />     

Safe control contains assembly name, namespace name

Q. Timer Job in SharePoint
It is a job in SharePoint that runs in background on a specified periodic basis.

public override void Execute(Guid targetInstanceId)

Execute is a override method which is responsible for executing timer job.

For more visit this link:

Q.Throttling and Indexing in SharePoint

List in SharePoint is similar to SQL table, indexing on List improve the performance.
A SharePoint list allow 20 indices. Not all column type can be indexed.
Throttling is a process which set the limit of item that will be accessed in a single request. Default limit is 5000.

For more see this link

List threshold can be overridden by using below property

for more visit this link:

Q. Create Child control in SharePoint
 private const string _ascxPath = @"~/_CONTROLTEMPLATES/MyProject.WebParts/MyVisualWebPart1/MyVisualWebPart1UserControl.ascx";

        protected override void CreateChildControls()
            Control control = Page.LoadControl(_ascxPath);


It does most of the rendering work related to a control such as label control, textbox control etc.
LoadControl(usercontrolpath) is a method which load web controls as per specified path.

Q. Webpart properties using C# code

Below code is to set webpart properties like width, chrome type, back color

protected override void CreateChildControls()       {
            Control control = Page.LoadControl(_ascxPath);
            ChromeType = PartChromeType.None;
            BackColor = Color.Red;
           Title = "This is a test title";
            this.ScrollBars = System.Web.UI.WebControls.ScrollBars.Both;
            this.Width = 500;


Q. What is GAC?
GAC stands for Global Assembly Cache

Q. Audience Targeting in SharePoint
It is a way to display list, library items to a specific groups of people. Go to list or library setting ->General Settings -> Audience targeting settings
Enable Audio targeting and click on ok.

Now go to list or library select any item, click on arrow and select edit properties.
You will now see a option for Audience Targeting.

Q. What is view in SharePoint?
View is the way to choose what data you want to present over web page. 
There are:
Standard View
Calendar View
DataSheet View
Gantt View
Custom View (In SharePoint Designer)

Q. Create a different view for folder inside a document library

Q. Document Set in SharePoint
Provides the content types required for creating and using document sets. Create a document set when you want to manage multiple documents as a single work product.

Q. ULS Log in SharePoint
ULS stands for Unified Logging Service
ULS helps a developer to find bugs without debugging an application.

catch(Exception ex)             {                
   SPDiagnosticsService spDiag = SPDiagnosticsService.Local;                
  spDiag.WriteTrace(0,new SPDiagnosticsCategory("My ULS Log", TraceSeverity.Monitorable, EventSeverity.Error), TraceSeverity.Monitorable, "ULS log error:  {0}",                                                         new object[] { ex.Message });                } 

ULS log viewer is a tool which present log details in a readable format.

Q. SPSiteDataQuery in SharePoint
It is use to get data from multiple list, and those lists could be in same site or in multiple sites.
CrossListQueryInfo is a another way to do this but internally it uses SPSiteDataQuery .

In SPSiteDataquery there are 2 scope that can be define.

<Webs Scope="Recursive" /> - Current website and all sub sites

<Webs Scope="SiteCollection" /> - All websites that are in current site collection

Q. Permission levels in SharePoint.

Full Control - Has Full control
Design - View, add, update, delete, approve
Contribute - view, add, update and delete items
Read - view pages and list items and download documents

Limited Access - Can view specific lists, document libraries, list items, folders or document on given permission

Q. Application Pages vs Site Pages
Application Pages stored in hive folder.
Site Pages stored in content database.

Application Pages support code behind.
Site Pages do not allow code behind.

Q. Data View Web Part
It is a way to display data with filtering. grouping.  Data View webpart was available in SharePoint 2007 and also available in 2010.
SharePoint 2010 also have XSLT Listview webpart.

XSLT Listview webpart - It is a webpart that can be modified in SharePoint designer using XSLT code.

Q. ONET.xml file
It is the core of site definition. It is located under hive folder.

Q. What are master pages available in SharePoint?
v4.master - Default team site master page.

default.master - This is the default master page for SharePoint 2007 look and feel.

minimal.master - Generally used by search centers.

simple.master - Used by SharePoint 2010 general pages like login page. error page, signout page etc.

Q. What is a Term?
A term is a keyword or phrase that can be associated with an item. A term set is a collection of related terms.

Q. Access Denied by Business Data Connectivity - Error in External List
Go to Central Admin-> Manage Service Application -> Click on Business connectivity service->
Select your External Content Type Name and click on Set Object Permission from top ribbon.

Type account name , then Add and select operation that you want to allow for this user.

Refer Below Screen -

error in external list

Q. Feature and Scope of feature available in SharePoint:
Feature is a set of code or functionality that can be activated or de-activated at various level to perform some change in SharePoint site.
Farm - It affects all web application available in a farm.
Web Application- It affects a complete web application.
Site- It affects a single site collection.
Web - It affects a single site

Q. Event Receiver
Event Handler and Receiver

There are 2 types of Events Before and After.
Generally known as Synchronous and Asynchronous events.

Event Receiver Base Class:


Event handler get registered in Elements.xml file. It includes Class name, assembly name, List template id.

If any method removed/added in receiver class same will reflect in Elements.xml file.



properties.Status = SPEventReceiverStatus.CancelWithRedirectUrl;

properties.RedirectUrl = "_layouts/EventRcvrApp/Error.aspx?msg=Item+Cannpt+be+deleted";

Q. Application Page vs Site Page vs Custom ASPX Page
Application Page
Site Page
Custom Page
Support Code behind
Do not support code behind
Can have code behind, but code behind file will not be deployed
They inherit from application.master
They inherit custom look of the site
Need to specify the url of custom master page
Stored in layout folder  available in hive folder
Stored in content database
Deployed in layout folder


Popular posts from this blog

CAML Query in SharePoint 2010

Calling REST APi from server side code - C#

All about SharePoint 2010 Content Type Hub

Calling ASP.Net WebMethod using jQuery AJAX