How my add-ins(Provider hosted) can know Host site URL where it is running?

Actually, In my case there are external and internal farm with different site URL (see below 2 URLs). Now, in my app, How to get the host site URL? There is single code which runs for both add-ins (external and internal).


External site: https://external.mycompany.com/sites/0028

Internal site: https://internal.mycompany.com/sites/0029

2 Answers 2


I am assuming that you have the code so you should have client id for both the apps. To check the host URL you can simply append "/_layouts/15/AppInv.aspx" to the site URL. For Example in your case it should be :

External site: https://external.mycompany.com/sites/0028/_layouts/15/AppInv.aspx

Internal site: https://internal.mycompany.com/sites/0029/_layouts/15/AppInv.aspx

On the page you can enter the client id and search, it will show you all the details related to app.

  • thx for reply. Yes, I already have Client ID in hand. My quest was - how my app when it runs, will know its Host URL? Commented Jun 12, 2018 at 8:15

Finally, I got it with HttpContext.Current.Request.Url.AbsoluteUri;

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.