Saturday, August 31, 2013

SharePoint 2013 - Creating a SharePoint 2013 App Part (Client Web Part)

We have already seen the different ways to create an app (SharePoint-Hosted, Provider-Hosted and Auto-Hosted).

Now we will take one step further and create an App Part which allows an app to be displayed inside a reusable webpart(rendered as an Iframe for displaying the app).

First of all, create a new project in visual studio 2012 selecting Apps for SharePoint 2013 located in Office/SharePoint->Apps as show in the following image.

Enter a suitable title, specify the Site collection where the app should be deployed and select SharePoint hosted. Click Finish to continue.

Right click on the project and select Add->New Item.

Select Client Web Part (Host Web), enter a suitable name and click Add button.

You will be prompted to choose one the following options: Create a new webpart page or Select existing page. We will go ahead by creating a new webpart page.

Note:- If you select the existing default.aspx page, you might run into an error indicating that the webpart isnot safe since it is wiki page. In this case you must add the following markup in the page.
<%@ Register Tagprefix="WebPartPages" Namespace="Microsoft.SharePoint.WebPartPages" Assembly="Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<WebPartPages:AllowFraming runat="server" />

The new webpart page will be created in the Pages folder as show in the figure below. Add some sample text to check the functionality.

Go to the newly created client web part. Give a suitable Title and set the source as the newly created web part page (set by default but you can change).


Deploy the solution

Go to the site where the app is deployed.

Choose the page where you wish to display the app part and open in edit mode.

Click on Add new webpart and select the app part you deployed as follows.
Select App Part->Client Web part Name

You will notice that the app part is now available on the page. It is nothing but an Iframe that displays the new webpart page that we created for the client web part.

Hope this post helps!

Friday, August 30, 2013

SharePoint 2013 - Creating a SharePoint 2013 Provider Hosted App

In this post we will go through the steps required to create a provider-hosted app.

Overview
Provider hosted apps are Cloud-hosted apps that use a third-party provider for hosting the web application rather than Windows Azure websites. The third-party provider can manually provision Windows Azure or can be based on anything else, even an on-premises server farm of your own. In provider hosted apps the browser request is sent to the SharePoint server which in turn calls the .Net Application as a Separate Application.

Steps for creating a Provider-Hosted App
Now lets create a Provider-hosted app for a SharePoint 2013 Team site created on Office 365.

1) Open Visual Studio 2012 and select Apps->App for SharePoint 2013.

2) Enter the URL of the Site collection where you wish to deploy the app and select Provider Hosted option. Click Next button.

3) On the second page, the Visual Studio wizard for creating a provider-hosted app asks you to choose between using Windows Azure Access Control Services (ACS) for authentication and authorization, rather than using a high-trust configuration based on a private certificate and asymmetric keys exchange.
The first choice is suitable when your app will be used on sites hosted on Office 365.
The second choice, High Trust, is suitable for on-premises scenarios.

4) You will notice that there are 2 projects (one for app and the other for web) created under the solution. Go to the Default.aspx and enter some sample text.

5) Right click on the app project and select publish.

6) The following window will pop up. Select New option and provide a name for the Profile. Click OK and then Next button.

In the next page you will be asked to provide the url where the site is hosted, a Client ID and a Client Secret.
Client ID is nothing but a guid but you can't create it from visual studio. For creating the Client ID go to the AppRegNew.aspx page. The page will present inside the layouts folder. The URL would be something like https://MyServer/sites/MySiteCollection/_layouts/15/Appregnew.aspx.
Go back to visual studio and copy the Client ID.


You will reach the final page of the wizard. Click Finish.

7) Once the app is published, the folder containing the .app file will open.

8) Now open the SharePoint site where you wish to deploy the app and click on the "new app to deploy" link.

9) The following popup will appear. Click on the upload link.

 10) Enter the .app file location for uploading the app to the site.

11) Once the app is successfully installed, click on Deploy button to deploy the app.

12) The app will seek for permission to deploy. Click on Trust It button to give permission.

 13) Once the app is successfully deployed, you can see it in the Site Contents page.

14) Click on the app and you will be navigated to the app page.


Wednesday, August 28, 2013

SharePoint 2013 - Creating a SharePoint 2013 Autohosted App

In this post we will discuss about the Autohosted apps for SharePoint 2013.

Overview
The Autohosted app model are created on sites which are already provisioned on Windows Azure websites.
Unlike SharePoint hosted apps, an app web is not present in autohosted apps for storing data. It uses its own SQL Azure based infrastructure instead and works only for SharePoint Sites hosted on Office 365 or SharePoint Online.

Steps for creating an Autohosted App
Now lets create an auto-hosted app for a SharePoint 2013 Team site created on Office 365.

1) Open Visual Studio 2012 and select Apps->App for SharePoint 2013.

2) Enter the URL of the SharePoint site which is hosted on Office 365 developer site. If you don't have an Office 365 developer account, you can easily signup for a 30 day trial account. You can see the detailed steps here.

3) Once you have created the Office 365 developer site account, enter the URL of the SharePoint Site where you wish to deploy the app and select Autohosted option.

4) You will notice that there are 2 projects (one for app and the other for web) created under the solution. Go to the Default.aspx and enter some sample text.

5) Right click on the app project and select publish.

6) The following window will pop up. Click on Finish button to publish the app.

7) Once the app is published, the folder containing the .app file will open.

8) Now open the SharePoint site where you wish to deploy the app and click on the "new app to deploy" link.

9) The following popup will appear. Click on the upload link.

 10) Enter the .app file location for uploading the app to the site.

11) Once the app is successfully installed, click on Deploy button to deploy the app.

12) The app will seek for permission to deploy. Click on Trust It button to give permission.

 13) Once the app is successfully deployed, you can see it in the Site Contents page.

14) Click on the app and you will be navigated to the app page.

SharePoint 2013 - Setting up a SharePoint 2013 Site on Office 365 Developer Site.

In this post we will look at the various steps for setting up a SharePoint 2013 developer site in Office 365.

1) Sign up for Office 365 Developer Site from here. (http://msdn.microsoft.com/en-us/library/fp179924.aspx)

2) You may opt for a 30 day trial edition to experience the Office 365 developer site. No credit card required.

3) Fill up the form with your personal details.
Note:- You may be required to enter a domain name for creating user account. You can enter a fictitious domain name just for development purpose.

4) Once you fill up all details and click Submit button, you will be redirected to your mail box. From there click Site option in the ribbon.

5) You will redirected to your personal site from where you can choose to create a Team site or a Public site. Choose the Team Site option.

6) Your new SharePoint 2013 Team site will be created.

Note:- You can use this for development purpose which is much more easier than going for a full SharePoint 2013 setup. But remember that this is only 30 day trial. You may need to purchase the licensed version for continuing after 30 days.