Skip to main content

Provider hosted apps


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

Popular posts from this blog

Identity client runtime library (IDCRL) did not get a response from the login server.

Recently I was doing some testing with a background PowerShell and encountered a weird error. “Identity client runtime library (IDCRL) did not get a response from the login server”. The error that you might encounter while working with PowerShell. This error is very misleading when it comes to identifying what could go wrong. After doing quite a good amount of research below are the probable causes for the error. Invalid Credentials MFA (Multi-Factor Authentication) Manage security defaults. Solutions Invalid Credentials Check if your credentials are wrong. Especially if you are using variables. MFA (Multi-Factor Authentication) Check if MFA is enabled on the account which you are using. These only affect you badly if you are developing PowerShell for a background Job. Go to Microsoft 365 admin center Users -> Active users -> Select the user -> Manage multifactor authentication -> Select the user -> Disable multi-factor authentication. M...

Business Data Connectivity

I came to a requirement wherein I was supposed to get data from an 3 rd party portal using API’s and then bring them to SharePoint server. The first approach that I finalized was just to make BDC solution that will get data from 3 rd party portal and will deploy it to SharePoint. How to Create BDC solution in SharePoint? I found below link that is having really great description about hot to create and deploy the BDC solution to SharePoint. http://www.c-sharpcorner.com/uploadfile/hung123/creating-business-data-connectivity-service-using-visual-studio-2010/ After creating an POC I came to know that BDC model cannot be deployed on Multi tenant farm. So what can be done next? After some amount of googling I came to know that we can create BDC solution using WCF services also. So I created a WCF service solution that acted as a wrapper that used to fetch data from the portal. We can them publish that service to IIS or Server and use the servic...

Site Design Tasks, Power Automate and Modern Sites

S harePoint Site templates are now replaced with Site designs in Modern Sites. We can create custom site designs using some json script(s). Site Design allows to create lists, create list views, apply theme, customize navigation, create content types, create site columns and so on. Click here to see JSON scheme reference for creating custom site design.  Endpoint to apply site design as a part of flow is as below. _api/Microsoft.Sharepoint.Utilities.WebTemplateExtensions.SiteScriptUtility.AddSiteDesignTaskToCurrentWeb We must use “Send Http Request to SharePoint” action to make an API call to SharePoint. SiteDesignId must be part if body, this is GUID of the SharePoint site design you need to apply. We can line up sequence of calls if we need to apply multiple site designs to a single site. We can now wait for few mins and all our sited designs will get applied or we can also check the status by making another API call with below endpoint. You just need to pass the Apply Desig...