Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Access host or URL info in Silverlight out-of-browser

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.

like image 891
Can Poyrazoğlu Avatar asked Jun 23 '11 01:06

Can Poyrazoğlu


1 Answers

You can get the address (even in OOB) using Application.Current.Host.Source

like image 94
RobSiklos Avatar answered Oct 27 '22 09:10

RobSiklos