Deploying MVC5 Based Provider Hosted Apps For On-Premise SharePoint 2013
Deploying MVC5 Based Provider Hosted Apps For On-Premise SharePoint 2013
Deploying MVC5 Based Provider Hosted Apps For On-Premise SharePoint 2013
i
3 Votes
https://spbreed.wordpress.com/2013/11/25/deploying-mvc5-based-provider-hosted-apps-for-on-premise-sharepoint-2013/ 1/22
10/30/2017 Deploying MVC5 based provider hosted apps for On-premise SharePoint 2013 | SPBreed's Blog
Why MVC:
Implementation:
This article does not cover how to set up App management Service
infrastructure on your SharePoint App stores. Follow this
informative article
(h p://sharepointchick.com/archive/2012/07/29/se ing-up-your-
app-domain-for-sharepoint-2013.aspx) by Mirjam
(h ps://twi er.com/MirjamvanOlst) to set up App domain.
https://spbreed.wordpress.com/2013/11/25/deploying-mvc5-based-provider-hosted-apps-for-on-premise-sharepoint-2013/ 2/22
10/30/2017 Deploying MVC5 based provider hosted apps for On-premise SharePoint 2013 | SPBreed's Blog
5)Deployment
Add a new Host (A) entry on DNS with the IP of Server hosting
remote web app. (sp2013apps.gsi.local)
(h ps://spbreed.files.wordpress.com/2013/11/dns.png)
https://spbreed.wordpress.com/2013/11/25/deploying-mvc5-based-provider-hosted-apps-for-on-premise-sharepoint-2013/ 3/22
10/30/2017 Deploying MVC5 based provider hosted apps for On-premise SharePoint 2013 | SPBreed's Blog
(h ps://spbreed.files.wordpress.com/2013/11/webdeploy-3-5.png)
(h ps://spbreed.files.wordpress.com/2013/11/service-delegate.png)
(h ps://spbreed.files.wordpress.com/2013/11/bypass-rules.png)
https://spbreed.wordpress.com/2013/11/25/deploying-mvc5-based-provider-hosted-apps-for-on-premise-sharepoint-2013/ 4/22
10/30/2017 Deploying MVC5 based provider hosted apps for On-premise SharePoint 2013 | SPBreed's Blog
Now click Management Service, stop the service and check “Enable
Remote Connections” checkbox to enable remote deployments. You
can optionally choose which IP address and port the management
service runs on – as well as what client IP addresses are allowed to
connect with it. You can tweak these se ings to lock down who can
access the deployment service.
(h ps://spbreed.files.wordpress.com/2013/11/remote-
connections.png)
(h ps://spbreed.files.wordpress.com/2013/11/443-iis.png)
https://spbreed.wordpress.com/2013/11/25/deploying-mvc5-based-provider-hosted-apps-for-on-premise-sharepoint-2013/ 5/22
10/30/2017 Deploying MVC5 based provider hosted apps for On-premise SharePoint 2013 | SPBreed's Blog
(h ps://spbreed.files.wordpress.com/2013/11/selfssl.png)
Where /S:1 key represents App Site ID of default website (Site ->
Advance Se ings -> General ->ID)
(h ps://spbreed.files.wordpress.com/2013/11/ssl_default.png)
Once the certificate is installed on your IIS, add new SSL binding
on 443 port with the host name registered before
https://spbreed.wordpress.com/2013/11/25/deploying-mvc5-based-provider-hosted-apps-for-on-premise-sharepoint-2013/ 6/22
10/30/2017 Deploying MVC5 based provider hosted apps for On-premise SharePoint 2013 | SPBreed's Blog
(h ps://spbreed.files.wordpress.com/2013/11/iis_ssl_apps.png)
(h ps://spbreed.files.wordpress.com/2013/11/iis8_logo.png)
Now repeat the steps 1.1 & 1.3 to SSL SharePoint WebApp.
https://spbreed.wordpress.com/2013/11/25/deploying-mvc5-based-provider-hosted-apps-for-on-premise-sharepoint-2013/ 7/22
10/30/2017 Deploying MVC5 based provider hosted apps for On-premise SharePoint 2013 | SPBreed's Blog
(h ps://spbreed.files.wordpress.com/2013/11/ssl_sp2013.png)
where SP2013.gsi.local is the host name for SharePoint web app and
/S:682683733 is the ID of SharePoint Webapp
(h ps://spbreed.files.wordpress.com/2013/11/aam_publicurl.png)
(h ps://spbreed.files.wordpress.com/2013/11/aam_internal.png)
Now perform IISRESET and wait few seconds until AAM timer job
updates the SharePoint routing tables.
https://spbreed.wordpress.com/2013/11/25/deploying-mvc5-based-provider-hosted-apps-for-on-premise-sharepoint-2013/ 8/22
10/30/2017 Deploying MVC5 based provider hosted apps for On-premise SharePoint 2013 | SPBreed's Blog
Export the certificate from the remote web server and copy to
Sharepoint environment
(h ps://spbreed.files.wordpress.com/2013/11/server_certs1.png)
Double click the SSL generated in last step -> details -> Copy to file -
> Donot export -> DER encoded
-> C:\Certs\selfsignedApps.cer
1 $publicCertPath = "C:\certs\selfsignedApps.cer"
2 $issuerId = [System.Guid]::NewGuid().ToString()
3 $spurl ="https://sp2013.gsi.local (https://sp2013
4 $spweb = Get-SPWeb $spurl
5 $realm = Get-SPAuthenticationRealm -ServiceContex
6 $certificate = Get-PfxCertificate $publicCertPath
7 New-SPTrustedRootAuthority -Name "<strong>Hightru
8 $fullIssuerIdentifier = $issuerId + '@' + $realm
9 New-SPTrustedSecurityTokenIssuer -Name $issuerId
https://spbreed.wordpress.com/2013/11/25/deploying-mvc5-based-provider-hosted-apps-for-on-premise-sharepoint-2013/ 9/22
10/30/2017 Deploying MVC5 based provider hosted apps for On-premise SharePoint 2013 | SPBreed's Blog
(h ps://spbreed.files.wordpress.com/2013/11/trust.png)
Double click .cert file -> Install Certificate -> Local Machine ->
Browse -> Trusted Root Certification Authorities -> OK
(h ps://spbreed.files.wordpress.com/2013/11/import_success.png)
Right click the SP2013apps.gsi.local -> export -> save with .pfx
extension and password
1 $issuerId = [System.Guid]::NewGuid().ToString()
2 $issuerId
https://spbreed.wordpress.com/2013/11/25/deploying-mvc5-based-provider-hosted-apps-for-on-premise-sharepoint-2013/ 10/22
10/30/2017 Deploying MVC5 based provider hosted apps for On-premise SharePoint 2013 | SPBreed's Blog
(h ps://spbreed.files.wordpress.com/2013/11/vs_1.png)
(h ps://spbreed.files.wordpress.com/2013/11/vs_providerhostoption1.png)
Now select the PFX certificate generated in the last step. Provide
password and Issuer ID
(h ps://spbreed.files.wordpress.com/2013/11/vs_cert1.png)
https://spbreed.wordpress.com/2013/11/25/deploying-mvc5-based-provider-hosted-apps-for-on-premise-sharepoint-2013/ 11/22
10/30/2017 Deploying MVC5 based provider hosted apps for On-premise SharePoint 2013 | SPBreed's Blog
(h ps://spbreed.files.wordpress.com/2013/11/mvc_solution-
structure.png)
Now Visual studio created two projects with in the same solution.
MVCApp1 is the SharePoint App and MVCApp1Web is the remote
webapp. Only artifact of the MVCApp1 is the appmanifest.xml.
This is similar to what feature.xml to WSP. We provide the version,
permission and startpage details of the app.
(h ps://spbreed.files.wordpress.com/2013/11/mvc_appmanifest.png)
https://spbreed.wordpress.com/2013/11/25/deploying-mvc5-based-provider-hosted-apps-for-on-premise-sharepoint-2013/ 12/22
10/30/2017 Deploying MVC5 based provider hosted apps for On-premise SharePoint 2013 | SPBreed's Blog
(h ps://spbreed.files.wordpress.com/2013/11/mvc_windowsauth.png)
Now you can directly debug the app by pressing f5. Now login to
app using your windows credentials and trust the app. This will
lead to sample app hosted from VS2013 if all the se ings are right.
(h ps://spbreed.files.wordpress.com/2013/11/mvc_sample.png)
https://spbreed.wordpress.com/2013/11/25/deploying-mvc5-based-provider-hosted-apps-for-on-premise-sharepoint-2013/ 13/22
10/30/2017 Deploying MVC5 based provider hosted apps for On-premise SharePoint 2013 | SPBreed's Blog
(h ps://spbreed.files.wordpress.com/2013/11/db_schema.png)
Right click model -> Add new item -> ADO.Net Entity datamodel ->
Generate from Database and connect to required Database objects
https://spbreed.wordpress.com/2013/11/25/deploying-mvc5-based-provider-hosted-apps-for-on-premise-sharepoint-2013/ 14/22
10/30/2017 Deploying MVC5 based provider hosted apps for On-premise SharePoint 2013 | SPBreed's Blog
(h ps://spbreed.files.wordpress.com/2013/11/mvc_db.png)
(h ps://spbreed.files.wordpress.com/2013/11/mvc_selec abe.png)
Now this will generate Model entities and classes to support CRUD
operations with the database
https://spbreed.wordpress.com/2013/11/25/deploying-mvc5-based-provider-hosted-apps-for-on-premise-sharepoint-2013/ 15/22
10/30/2017 Deploying MVC5 based provider hosted apps for On-premise SharePoint 2013 | SPBreed's Blog
(h ps://spbreed.files.wordpress.com/2013/11/mvc_model.png)
Now right click controller -> Add -> New Scaffolding Item -> Select
MVC5 Controller with views using entity frame work
(h ps://spbreed.files.wordpress.com/2013/11/mvc_scafold.png)
This will generate all controller and View files. View files are in
.cshtml format. This can be edited to suit our design. (More on this
in next blog post)
https://spbreed.wordpress.com/2013/11/25/deploying-mvc5-based-provider-hosted-apps-for-on-premise-sharepoint-2013/ 16/22
10/30/2017 Deploying MVC5 based provider hosted apps for On-premise SharePoint 2013 | SPBreed's Blog
(h ps://spbreed.files.wordpress.com/2013/11/mvc_views.png)
With MVC there is no direct URL access. Its all view containers is
what we need. And the URL re-direction logics are stored in the
RootConfig.cs located under App_Start folder
(h ps://spbreed.files.wordpress.com/2013/11/mvc_rootconfig.png)
5)Deployment
App Deployment:
Before publishing the app, a new client ID for the App should be
generated form the app site. SharePoint uses this client ID to
validate the App file while installing. Navigate to appregnew.aspx
(h ps://spbreed.files.wordpress.com/2013/11/mvc_appreg-
new2.png).
https://spbreed.wordpress.com/2013/11/25/deploying-mvc5-based-provider-hosted-apps-for-on-premise-sharepoint-2013/ 17/22
10/30/2017 Deploying MVC5 based provider hosted apps for On-premise SharePoint 2013 | SPBreed's Blog
Right click the solution and click publish and select Package the
app. And enter the client ID and the remote site URL.
(h ps://spbreed.files.wordpress.com/2013/11/mvc_pub_se ings.png)
(h ps://spbreed.files.wordpress.com/2013/11/mvc_spapp1.png)
On opening the .app file with good old WINRAR all the resources
can be extracted out. And verify appmanifest.xml .
https://spbreed.wordpress.com/2013/11/25/deploying-mvc5-based-provider-hosted-apps-for-on-premise-sharepoint-2013/ 18/22
10/30/2017 Deploying MVC5 based provider hosted apps for On-premise SharePoint 2013 | SPBreed's Blog
(h ps://spbreed.files.wordpress.com/2013/11/mvc_manifestpic.png)
(h ps://spbreed.files.wordpress.com/2013/11/appmanifest.png)
WebSite Deployment:
Now go back to Publish page and click “Deploy your Web Project”.
Select a new profile and enter the details of remote web server and
client ID se ings.
https://spbreed.wordpress.com/2013/11/25/deploying-mvc5-based-provider-hosted-apps-for-on-premise-sharepoint-2013/ 19/22
10/30/2017 Deploying MVC5 based provider hosted apps for On-premise SharePoint 2013 | SPBreed's Blog
(h ps://spbreed.files.wordpress.com/2013/11/mvc_publish1.png)
(h ps://spbreed.files.wordpress.com/2013/11/mvc_spapp1.png)
Now add the installed app from any site and trust it. On clicking
the app page will be redirected to index
page h ps://sp2013apps.gsi.local/MVCApp1/customer/
https://spbreed.wordpress.com/2013/11/25/deploying-mvc5-based-provider-hosted-apps-for-on-premise-sharepoint-2013/ 20/22
10/30/2017 Deploying MVC5 based provider hosted apps for On-premise SharePoint 2013 | SPBreed's Blog
(h ps://spbreed.files.wordpress.com/2013/11/mvc_index.png)
Advertisements
https://spbreed.wordpress.com/2013/11/25/deploying-mvc5-based-provider-hosted-apps-for-on-premise-sharepoint-2013/ 21/22
10/30/2017 Deploying MVC5 based provider hosted apps for On-premise SharePoint 2013 | SPBreed's Blog
1. fabiangwilliams
NOVEMBER 25, 2013 AT 9:17 PM
Really good tutorial, love your style of writing lol, it matches my
own, visual learner so i need plenty of pics. Cheers
REPLY
spbreed
NOVEMBER 25, 2013 AT 10:40 PM
Thanks Fabian. Didn find much on se ing up s2s
infrastructure. Hence detailed it.
REPLY
2. Pingback: Nova Tech Consulting Blog | Deploying MVC5 based
provider hosted apps for On-premise SharePoint 2013
3. SV
MARCH 25, 2014 AT 6:19 PM
Can we associate a workflow to this provider hosted app? What
sort of events can it be bound to while associating a workflow?
REPLY
https://spbreed.wordpress.com/2013/11/25/deploying-mvc5-based-provider-hosted-apps-for-on-premise-sharepoint-2013/ 22/22