0

I started to study how we can reproduce our project in a SharePoint 2013 app. I've made some test and I saw that the provider hosted app generates a normal web application that will be hosted outside SharePoint environment.

I have some question about.

How create site pages?

Usually in a farm solution I create a Visual Web Part and the site page using CAML declarative mode with a module and a base layout aspx page.

How can I reproduce it in this new context? Can I to create a client web part and the page as before?

How to get SPContenxt?

I saw that when I start my project Default.aspx opens with SPHostUrl query string that is used to get ClientContext in Page_Load event. So, wherever I need to interact with SharePoint I have to open the page with this query string? Is there some other "more elegant" way to generate this query string instead to hard code it? And I have to refresh it? I saw method to refresh the access token.

Get SPHostUrl in web application

I find that in mark up I can create a link link with href='javascript:location.href="Page.aspx" + location.search' that redirects me to Page.apsx with SPHostUrl query string, is there a way to do it also in server side code?

Web service

Cannot add ISAPI folder anymore, have I to create a custom WCF service and deploy it in the remote web app url?

Thank you for your help.

1

So you are actually trying to translate a farm solution to a O365 friendly solution?

What can a provider-hosted app do?

A lot - BUT

A provider-hosted app isn't a generic replacement for farmsolutions. It's a solution with specific field of use. I like to compare them to custom webparts and application pages. It CAN do more, but likely there are better ways.

How to create elements (pages, webs, lists, etc.)?

  • Declarative in a NCSS (No Code Sandboxed Solution)
    • Quite limited but still valuable for most scenarios
  • CSOM Provisioning

If you want to provision pages and webs, the answer is CSOM. It does not really matter if you package that CSOM in a provider-hosted- / sharepoint-hosted-app, a simple console application or something else.

The people behind Office PnP created a awesome provisioning engine that can consume declarative templates https://msdn.microsoft.com/en-us/pnp_articles/pnp-provisioning-engine-and-the-core-library.

How to get the SPContext?

It's ClientContext in CSOM and you will find here all answers https://sharepoint.stackexchange.com/a/134489/10271

Get SPHostUrl in web application

The URL is given via the querystring when the app is called. Create a hello world app and you will see.

Web service

A provider-hosted app is essentially a IIS-hosted website that can make secure connections to sharepoint. You have to create at least that. If you need a webservice you can do so, but it's not necessary for a provider-hosted app.

You have to know that you can't call the webservice directly from SharePoint (cross-origin) but only in your providerhosted-app context.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.