Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get hosting website url in silverlight application?

Silverlight App is hosting on a web site. How to get the hosting url in silverlight app code? For example if the hosting site is http://mysite/startingpage.aspx, then how to get "http://mysite" in SL app code?

like image 754
KentZhou Avatar asked Jul 06 '12 19:07

KentZhou


1 Answers

This will give you the location of the page hosting the .xap file:

var pageUri = System.Windows.Browser.HtmlPage.Document.DocumentUri.ToString();

This will give you the location of your .xap file:

var applicationUri = System.Windows.Application.Current.Host.Source.AbsoluteUri;

You can then take either of these strings and parse out the parts you don't need.

like image 77
Kevin Aenmey Avatar answered Nov 02 '22 09:11

Kevin Aenmey