Provider Hosted Application is very useful to re-use the existing
.Net application with very minor changes and their hosting environment. The
topology of the Provider Hosted Application is as follows.
The user calls the SharePoint server and the SharePoint
portal intern calls the .Net Application as a Separate Application. Moreover,
there is an option to create an App Part and loads the .Net Application inside
the App Part which can be placed on the SharePoint Page.
Below are the steps that you need to follow to
create yours provide hosted app.
1.
Create a
SharePoint site of Developer’s template.
2.
You need to create
an Webapp on Azure or any server that can be connected using internet. For creating using Azure login to azure management portal. Click on new > WebApp
> Quick Create > Specify name of web app > Now keep note of the link
of webapp.
Visit the Dashboard of the Web app that is just
created.
Click on Download the publish profile button.
This will download an xml that will be needed to publish the App to the web
that we just created.
3.
Now open the site
that you just created and visit below link in order to generate Client Id and
Client Secret.
“/_layouts/15/AppRegnew.a spx”
When you visit
this link you will find below screen. Click on generate for client id and same
for secret key. Now let’s say the url of the generated site is https://abc.net.
Keep copy of
generated client id and secret id.
Note:
Make sure you are doing this for the Developer template’s site.
Client
ID. A 16-character string that
represents your application. Record this string for later use.
Secret
key. A security key that Windows Live
ID uses to encrypt and sign all tokens that it sends to your site. You should
record this key, but we recommend that you do not store it in the same location
as its corresponding client ID.
4.
Now let go to visual studio and
create a SharePoint App project.
Steps to Create a Provider Hosted Application:
I. Open the Visual Studio 2012 as Administrator
II. Click New Project.
III. Select the Template App for SharePoint 2013.
IV. On the Creation of the Solution, Visual Studio will ask for the
Site Collection against which we are going to deploy our app. And on the same
screen, we need to choose the type of hosting which we are planning. In our
case, it is going to be Provider Hosted Application.
V. On the selection of Provider Hosted, Click Next. The below
screen will be asking the Certificate.
VI. Now, the Solution has been created. The basic solution is as
follows.
VII. Our solution will comprise of 2 projects.
a. App Project
b. AppWeb Project
VIII. App Project – This is going to be deployed on the SharePoint.
IX. AppWeb Project – This is going to be the .Net Web Application.
This application can be hosted on any IIS or let’s say on the webapp that you
created on azure.
5.
Now open the SharePoint WebApp
project and edit its web.config file.Copy and paste the client id and secret id that you created above
to web.config file.
6.
Now right click the webapp project
and click on publish. You will find below screen.
Now click on import and select the file that you
downloaded when you created webapp on Azure.
If file is successfully imported, you will see
below screen.
Note: Make sure the destination url starts
with https.
7.
Now let’s go the
app project and open the manifest file. In the permissions tab select web and
set permission to full control. Each time you modify app project make sure you
update its version.
8.
Open them code of
manifest file and replace the astric ”*” sign with the generated client id.
9.
Now right click on
the app project and click on publish. In that if select new from the dropdown
and select the file that we downloaded from azure webapp.
10. Now click on edit besides the dropdown list and
you will find below screen. Paste client id and secret id in that dialog. Then
click on deploy your web project.
Note:
Just like webApp project in connection tab make sure the webapp url starts with
https
11. Now click on package the app, a file explorer
will be opened and you now just need to upload this app to your site.
12. Open the site that you created of type developer’s
template. Go to app packages library and upload the app file over here.
13. Now go to app in testing library and select the
app that you just uploaded and that’s it in site contents you can see the app.
14.
Click on the app
and your app in loaded now.
Note: In case you get some error try to open the
url in fiddler in order to know the error that is thrown..
Regards,
Keyur Pandya
Comments
Post a Comment