5

I need to pass a query string to provider hosted app in SharePoint 2013 Online

1
  • If you provide more information on context, what type of query string, possible parameters and other relevant stuff to the question you have a better chance getting an accurate answre. Thank You!
    – Benny Skogberg
    Commented Jul 8, 2014 at 8:15

3 Answers 3

4

As explained here in MSDN we need to app redirect something like this

https://{SharePoint Server Name}/_layouts/15/appredirect.aspx?client_id={the app client Id}&redirect_uri={URL}

Client Id - would be the "App Identifier" from the Site App Permissions page.

Redirect URI - will be the app url you get when you navigate to.

Both these query strings need to be HTML encoded. Follow the instruction in here for more details.

Ok, once you have the app redirect working, just append the Redirect_Uri with your query string :)

1
  • 1
    Hey, thanks for this solution. Apparently using that appredirect.aspx with my client id and redirect uri does redirect me back to my app but it doesnt send any query string with it. It cant be the aim that I send my query string with it as the AppRedirector just supplied me with those... It should be able to do so again!
    – Vinz
    Commented Mar 23, 2015 at 11:28
1

To actually answer this query... Add your query string parameters to the redirection path i.e. /_layouts/15/appredirect.aspx?client_id={the app client Id}&redirect_uri={URL}&newParam=hello&param2=see this

Then inside your provider hosted web, simply query the referrer url instead of the request url.

string vstrQueryStringUrl = Request.UrlReferrer.AbsoluteUri;
1

Script to get the current page URL/pass the query string from the Provider hosted app you can use PostMessage API concept

Script to get the current page URL/pass the query string from the SharePoint hosted apps var currentPageURL = (window.location != window.parent.location) ? document.referrer : document.location;

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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