Silverlight is an RIA so the application only live on the client side. Sometime it's a good idea to store parameters on the web.config file (i.e a web service endpoint).
Of course it's impossible to read the configuration file directly from the application running on the client.
What's the workaround ?
The Silverlight application is host on an aspx page in a
string _baseUrl = ConfigurationManager.AppSettings["EndPointAdress"];
After you must give this parameters to the Silverlight asp.net control, you can do that via his InitParameters property :
SLControl.InitParameters = "EndPointAdress=" + _baseUrl;
private void Application_Startup(object sender, StartupEventArgs e)
{
string _baseUrl = e.InitParams["BaseUrl"];
}
That's all ! :)
Aucun commentaire:
Enregistrer un commentaire