SharePoint hosted App: An overview

My SharePoint hosted App uploaded to Microsoft store available at

This blog explains about my understanding on App model and SP hosted apps.

Microsoft have added advanced hosting mechanisms to SharePoint 2013, which provides necessary platform to host apps.

SharePoint hosting is a fundamental model in this. Provider hosted is little advanced which will be discussed later.

Development environment:

I am not going to delve deep. But Microsoft recommendation is to have 24GB of RAM for typical dev setup. If you are planning to run Search services, at-least 16GB is recommended. I tried running search SSA’s with my 8GB RAM and It was too slow. Finally after a day of trying various resource utilization techniques I uninstalled Search SSA’s.

After installing SharePoint 2013, follow this excellent article by Mariam to set up App domain.

Understanding of SharePoint hosting:

Microsoft realized Apps/App markets are inevitable to future software industry. To support apps the hosting model plays a key role with isolation, security and storage capabilities. To provide isolation SharePoint apps are created as separate Web apps and for each app installation SharePoint creates a new web app.

This design is made possible through Host web & App Web. App Web is a site dedicated to the App artifacts. When the app is deployed with the list or content type provisions, it will be created in these app-webs. And host webs just use IFrame html viewer to see this data.

Thanks to Chris & Doug for providing a clear explanation.

SharePoint hosted APP:

Install Office developer tools Preview 2 to your Visual studio 2012.

1) Create a Developer site collection form central Admin

2) Open VS & select “App for SharePoint 2013” under VS2012 Office/SharePoint -> Apps

3) Now select Dev site created at step-1 and select “SharePoint-hosted” as options

4) Once VS validates the connection to Dev site, a new App Project will be created.

I my next blog we can see an example of this:


Analysing network traffic – troubleshooting

Many occasions while configuring the FAST SSA’s with custom pipelines, crawl rate will be very less.

Sometimes, the issues might be due to network settings. Follow these steps to debug these issues.

Please see the steps below in order to configure Network Monitor:

1a. Turn off TCP Chimney if any of the machines are Windows 2003
Option 1) Bring up a command prompt and execute the following:
Netsh int ip set chimney DISABLED
Option 2) Apply the Scalable Networking Patch –;EN-US;936594

1b. Confirm that TCP Chimney is turned off if any of the machines are Windows 2008 and the driver is older than January 2010 (see for more details)
a) bring up a command prompt and execute the following:
netsh int tcp show global
b) if it turns out TCP Chimney is on disable it
netsh int tcp set global chimney=disabled

2.  Turn off TCP Offloading/Receive Side-Scaling/TCP Large Send Offload at the NIC driver level

3.  Retry your application.  Don’t laugh – many, many problems are resolved by the above changes.

4.  Download Network Monitor

5. Install Network Monitor on both the client and server experiencing the problem.  If you are not able to install it on the server you can install it on another machine that is connected to the same hub as the server or to the admin port of the switch that the server is on.  If you go this route you must synchronize the time between the client, server, and this third machine.

6.  Synchronize the clocks on the Client and SQL machines
a)  At one of the machines bring up a command prompt and execute the following:
Net time <\\machinenamewewanttosynchwith> /set /yes

7. Using the NMCap command-line utility, start the chained trace (chained = create a new capture file after reaching the “Temporary capture file size” rather than overwriting the current capture)
a) [Netmon 3 installation folder]\NMCap /network * /capture /captureprocesses /file test.chn:25M /UseProfile 45c7af5a-d264-4243-90df-fb97082c52ac (creates 25 MB chained files)
c) NOTE:  The target folder must exist for NMCap to create the trace file

8. Flush DNS
a) ipconfig /flushdns

9) If dealing with an authentication failure, you will now want to purge the Kerberos tickets
a) klist tickets tgt purge

10. Get the IP addresses of the client and the server
a)  ipconfig /all on the client > client.txt
b)  ipconfig /all on the server > server.txt

11. Reproduce the problem, please note the exact time the problem reproduces.  Also, please note the exact error message.

12. Stop the trace by hitting Ctrl-c in the command-line window

IMPORTANT: Please remember to let me know the IP addresses of the server and client as well as the time that the problem occurred.

More information can be found at:


by running the command-line switch /examples


by running the command-line switch /?

Powershell script to update masterpage:

 $csvOutPutName = "masterPageOutput-ts.csv"
 [string]$siteUrl = $args[0]
function GetMissingParameter {
 $script:siteUrl = read-host "Enter Site URL"
function ProcessDirectory($directory, $spfolder) {
 foreach ($file in $directory.GetFiles()) {
 $docUrl = $spfolder.Url + "/" + (Split-Path $file -Leaf)
 $fileToUpdate = $spfolder.ParentWeb.GetFile($docUrl)
if ($fileToUpdate.Exists) {
 $newfile = $spfolder.Files.Add($file.Name, $file.OpenRead(), $true)
 $newfile.CheckIn("Checked-in file via PowerShell script.")
if ($newfile.Level -eq "Draft") {
 $newfile.Publish("Published file via PowerShell script.")
 if ($newfile.Level -ne "Published") {
 $newfile.Approve("Approved file via PowerShell script.")
Write-Host Uploaded file $file.Name to $spfolder.Name
 if($args.length -eq 0) {
$site = New-Object Microsoft.SharePoint.SPSite($siteUrl)
 $impactedSites = @()
cd Masterpages
 $currentfolder = get-item .
Write-Host "Copying masterpage files to $($site.Url)..." -foregroundcolor Yellow
foreach($web in $site.AllWebs) {
 $obj = New-Object PSObject -property @{ Url = $web.Url; OldCustomMasterPage = $web.CustomMasterUrl; OldMasterPage = $web.MasterUrl; SiteType = "Web"; }
 $obj | fl
$masterpageGallery = $web.GetCatalog(116).RootFolder
 ProcessDirectory $currentfolder $masterpageGallery
$impactedSites += $obj }
cd ..
$impactedSites | ft
 $impactedSites | Export-Csv -Path $csvOutPutName -NoTypeInformation

set primary and secondary Site Collection Administrator through PowerShell

This script reads the CSV in the below format

and update the primary and secondary admins

#Get Site collection URL as a parameter
 #[string] $filePath = $(Throw "Missing Input - CSV file path required with filename. Ex: E:\input\Archivingsites.csv"), #required parameter
 #[string] $LogFilePath = $(Throw "Missing Input - Path to create log file. Path al Ex: E:\input\") #required parameter

#Load SharePoint dll file
 [void] [System.Reflection.Assembly]::Load(”Microsoft.SharePoint, Version=, Culture=neutral, PublicKeyToken=71e9bce111e9429c”)

$filePath = "E:\Scripts\UpdateOwnership\UpdateOwnership.csv"
 $csv_info = Import-Csv $filePath

#Logfile Name and Path
 $LogFilePath = "E:\Scripts\UpdateOwnership\"
 $date = ( get-date ).ToString('yyyyMMdd')
 $FileName = "UpdateOwnershipSitesLog_"
 $FileName = $LogFilePath += $FileName += $date

#Creating Log file
 if(!(Test-Path -Path "$FileName.txt"))
 $file = New-Item -type file "$FileName.txt"

Write-Host "--Begin Process--"
 Add-Content -Path "$FileName.txt" -Value "Begin Process"

#iterate Csv File
 foreach ($line in $csv_info)

Write-Host "--starting update for site: " $line.Url " PrimaryOwner: " $line.Owner " & SecondaryOwner: " $line.SecondaryOwner
 Add-Content -Path "$FileName.txt" -Value $( "--starting update for site: " + $line.Url + " PrimaryOwner: " + $line.Owner + " and SecondaryOwner: " + $line.SecondaryOwner)
 #Get site collection
 $site = new-object Microsoft.SharePoint.SPSite($line.Url.Trim())
 $web = $site.RootWeb
 $users = $web.SiteUsers
 $PrimaryOwner = $web.SiteUsers[$line.Owner.Trim()]

 Write-Host "Please add primary owner to " $site
 Add-Content -Path "$FileName.txt" -Value $("Please add primary owner to " + $site)
 $site.Owner = $PrimaryOwner
 Write-Host "Primary owner :" $PrimaryOwner "is successfully added to " $site
 Add-Content -Path "$FileName.txt" -Value $("Primary owner: " + $PrimaryOwner + "is successfully added to " + $site)

 $SecondaryOwner = $web.SiteUsers[$line.SecondaryOwner.Trim()]
 Write-Host "Please add secondary owner to " $site
 Add-Content -Path "$FileName.txt" -Value $("Please add secondary owner to " + $site)
 $site.SecondaryContact = $SecondaryOwner
 Write-Host "Secondary owner :" $SecondaryOwner "is successfully added to " $site
 Add-Content -Path "$FileName.txt" -Value $("Secondary owner: " + $SecondaryOwner + "is successfully added to " + $site )


Add-Content -Path "$FileName.txt" -Value "End Process"
 Write-Host "--End Process--"