1

I'm currently evaluating development approaches for provider-hosted apps for SharePoint Online.

I already found the Office PnP samples, which are a quite good start.

But there is one question I could not find a solution so far.

I want to place a simple link in my host web to my app in the remote app (javascript override).

How can I get the remoteurl?

I assume that it is stored somewhere because I have to enter it during app registration.

Thanks in advance, Florian

Community
  • 1
  • 1
Florian
  • 11
  • 3
  • Hi Florian, we are also using provider hosted apps. Just to help me understand your question... where exactly do you want to link your provider-hosted app? The proper approach would be to install an app part on a sitecollection which links to your remote app. This would be achieved by registering the app properly in sharepoint. (It could be that I'm understanding you completely wrong - sorry.) – bloC May 10 '16 at 09:33

1 Answers1

0

So here is the approach: 1. Add an aspx page in App project(not in remote web). 2. In aspx page add

 <WebPartPages:AllowFraming ID="AllowFraming1" runat="server" />
    <head>
    <title></title>
    ...Add Head content 
    </head>
    <body>
    <a href='#' target="_parent" id="btnABC">
       Your Link</a>   
    <script type="text/javascript">
        var params = document.URL.split("?")[1].split("&");
        var stdTokens = document.URL.split("?")[1];      
        var appRURL;       
        for (var i = 0; i < params.length; i = i + 1) {
            var param = params[i].split("=")
            if (param[0] == "appRURL") {
                appRURL = decodeURIComponent(param[1]);
            }           
        }        
        document.getElementById("btnABC").href = appRURL + "/Home/Index/?" + stdTokens;      
    </script>   

    </body>
  1. Now, Add the client web part in same project and in source choose just created aspx page which might look like "~appWebUrl/Pages/Your.aspx"and content tag looks like

  1. You are ready. Install the app in your host web and add this web part where you want to add Remote Web link.
Akash
  • 3
  • 2