Friday, August 10, 2012

How to get current URL in or Silverlight?

How to get current URL in or Silverlight?

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:

Sample for Xap Name
Get the full URL of the page hosting the xap (with QueryStrings):

Sample for hosing page URI
Uri SourceUri = new Uri(HtmlPage.Document.DocumentUri, Application.Current.Host.Source.ToString().Substring(0,Application.Current.Host.Source.ToString().IndexOf("ClientBin") -1));

It will return


No comments:

Post a Comment