I'm building a Silverlight app which will be deployable to different websites easily, and from within the application, I need to access the domain/host that the Silverlight is hosted at. So, I know for apps within the browser window, this code would perfectly work:
HtmlPage.Document.DocumentUri.Host;
The problem is, I need this app to be installed and be run in out-of-browser mode too. However, when I call the same code in OOB mode, I get an exception, which is perfectly normal as SL in not running in a browser. But logically, the SL app has been installed from somewhere, and I need to access that "origin" URL (or at least, the original host is enough for me in this project). Simply put, if the app is installed from http://example.com/example.xap, how can I access the very string "http://example.com/example.xap" programatically while running out of browser? I won't be knowing this in advance as the app will be modular and be deployed to any domain. Is creating a settings file in isolated storage and setting the domain string if not set the only option, or is there a more trivial way?
Thanks, Can.
You can get the address (even in OOB) using Application.Current.Host.Source
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With