Article 12 from 30 : How to use MVC web project for auto-hosted and provider-hosted sharepoint apps

This post is article 12 from the 30 Articles App series for SharePoint

Today, I will discuss about how you can use the MVC4 web project with your provider or Auto hosted app. And so you can take all the advantages of the latest MVC 4 features with SharePoint Apps.

1) Let’s start with auto/Provider hosted App with default template.

2) Add new project -> select web -> MVC4 web project and create.

20121119-170037.jpg

3) Add TokenHelper.cs file

20121119-170044.jpg

4) Add below references to MVC web project.

  1. Microsoft.Identity
  2. Microsoft.Identity.Extentions you can find it here : C:\Windows\Microsoft.Net\assembly\GAC_MSIL\Microsoft.IdentityModel.Extensions\v4.0_2.0.0.0__69c3241e6f0468ca\Microsoft.IdentityModel.Extensions.dll
  3. Microsoft.SharePoint.client
  4. Microsoft.SharePoint.client.runtime
  5. System.identitymodel

20121119-170050.jpg

5) Changes to web.config file:

Add appropriate clientId and client Secret under -> section.

6) Make sure that your MVC web is SSL enabled.

7) Now reference this MVC web project as remoteApp web project for your Auto/Provider Hosted App.

right click the SharePoint App project -> choose properties.

Change the property of SharePoint App project -> Web project => select above mvc web project

20121119-170056.jpg

Done. Now you can use you MVC web project with SharePoint Auto/provider hosted app.

Hope that helps..!!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s