Alternatives to using WebClient.BaseAddress to get base url in Silverlight

Posted by Martin Liversage on Stack Overflow See other posts from Stack Overflow or by Martin Liversage
Published on 2009-07-24T14:52:53Z Indexed on 2010/04/12 16:33 UTC
Read the original article Hit count: 670

Filed under:
|
|

In a Silverlight application I sometimes need to connect to the web site where the application is hosted. To avoid hard coding the web site in my Silverlight application I use code like this:

WebClient webClient = new WebClient();
Uri baseUri = new Uri(webClient.BaseAddress);
UriBuilder uriBuilder = new UriBuilder(baseUri.Scheme, baseUri.Host, baseUri.Port);
// Continue building the URL ...

It feels very clunky to create a WebClient instance just to get access to the URL of the XAP file. Are there any alternatives?

© Stack Overflow or respective owner

Related posts about Silverlight

Related posts about url