How to get current URL in asp.net 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:
App.Current.Host.Source.AbsoluteUri
Sample for Xap Name
http://www.myhost.com/ClientBin/SilverlightApplication1.xap
Get the full URL of the page hosting the xap (with
QueryStrings):
HtmlPage.Document.DocumentUri.ToString()
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 http://www.myhost.com/
Thanks!
No comments:
Post a Comment