In this post I will explain how to add a view of your provider-hosted MVC app as an App part in your sharepoint tenant.
- To start with create a provider-hosted MVC app using visual studio 2013
- It creates two projects in your solution. One is a sharepoint app and other is the web app that is the normal MVC project.
- In the solution add a new item in the sharepoint project. Select Office/Sharepoint in the types and then select ‘Client Web Part (Host Web)’ . Give it a suitable name according to your view.
- On the next screen set Url for the app part, since I wanted to load Survey controller’s Index View, I put below Url
- Press F5 which re-installs the app with new changes and asks to verify if you ‘trust it’ again.
- After that go to the page where you want to install the app part and in the Page menu tab, hit Edit. Then click on insert and select App Part:There in the list you can see the Client Web part which we added in the sharepoint App (AppPollWebPart). Select that, hit add and Voila! Its added on the page. Hit save to save the page and your web app is rendered in the little Iframe on the page. You can see the index view in that Iframe.
- Further you can make changes in the appearance of the app part by editing it. Here are the screen caps for that.
You can create a cool dashboard page in your sharepoint tenant with many such cool app parts to display stats, News feeds etc.
Do you have anymore documentation on this ?
Thank you for sharing this, have been looking everywhere.
LikeLike
Glad that it helped you. Here is my code and other details for this little project : https://github.com/shwetayadkikar/SignalR-SharepointAppParts
Let me know if you need more information. Thanks.
LikeLike
Hi Shweta,
I have a provider hosted app work fine as full page app with all event firing well. But when I add this app as client WebPart or app part. The page loads well but if there is any events like button click this app part get into continuous reloading . Any one faced this issue?
LikeLike
Haven’t faced anything like this. But I would let you know if I find anything related to this issue.
LikeLike
My Solution for this:
https://platinumdogs.me/2015/03/06/enable-iframing-in-a-sharepoint-provider-hosted-mvc-app/
LikeLike