Get Silverlight xap and hosting page URL

Very simple but I am often asked this during trainings:

Get the URL to the current xap file:
    App.Current.Host.Source.AbsoluteUri

Sample:
    http://www.myhost.com/ClientBin/SilverlightApplication1.xap

 

Get the full URL of the page hosting the xap (with QueryStrings):
    HtmlPage.Document.DocumentUri.ToString()

Sample:
    http://www.myhost.com/SilverlightApplication1.aspx?param=1

No Comments