I have a SharePoint add-in that create a "button" on the page ribbon. When the user clicks on the button, it makes a call to a provider hosted app that resides in Azure. The request goes through, but I need to know the URL of the page where the button was clicked. For example, the page where the icon is clicked is:


In my AppManifest.xml, I have the following:


In my elements.xml, I have the following:

<UrlAction Url="~remoteAppUrl/ContentExport.aspx?{StandardTokens}&amp;SPSource={Source}&amp;SPItemURL={ItemUrl}"></UrlAction>

<CommandUIHandler Command="Invoke_ContentExportAction3ButtonRequest"

The ItemUrl does not get resolved, which I believe makes sense for a StartPage. The source gives me the following:


Is it possible to get the URL of Test4.aspx?

1 Answer 1


Can you try this -

  1. Get the current url of the SharePoint site.

    Asp.Net - System.Web.HttpContext.Current.Request.Path

    Javascript - window.location.href

  2. Pass it to the app as a url parameter -

  3. Decode it in the app

  • How do I specify the javascript in the CommandAction as it needs to start with ~remoteAppUrl. CommandAction="javascript: .... does not work.
    – SaulR
    Commented Jul 12, 2017 at 0:40
  • How are you redirecting the user on the button click, are you using href tag? or is it an aspx button? Commented Jul 12, 2017 at 8:39
  • aspx button. Clicking on the icon in the ribbon causes an aspx page to be displayed. The user then fills out the information and clicks on a button at the bottom of the page. In the code behind for that aspx page, I need the URL of the page when the user clicked on the icon in the ribbon which is the itemUrl. In my elements.xml file, how can I add in the Javascript to get the current URL and pass that into the CommandAction.
    – SaulR
    Commented Jul 12, 2017 at 16:10

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.