Dear All,
How to use web config app settings in silver light application page.
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Manikavelu VelayuthamPosted Jul 18, 2011, 6:29 AM
http://blogs.msdn.com/b/luc/archive/2009/05/29/reading-web-config-parameters-from-a-silverlight-application.aspx
Gomathi PalaniswamyPosted Jul 18, 2011, 2:07 AM
Thanks for your reply.I would like to get value with out creating xml page.Can you please say some other way to access web.config appsetting value.
Jaganathan BantheswaranPosted Jul 15, 2011, 5:18 AM
You can use WebConfig file like,
And you can access the file as like,
public static string GetSomeSetting(string settingName)
{
var valueToGet = string.Empty;
var reader = XmlReader.Create("XMLFileInYourRoot.Config");
reader.MoveToContent();
while (reader.Read())
{
if (reader.NodeType == XmlNodeType.Element && reader.Name == "add")
{
if (reader.HasAttributes)
{
valueToGet = reader.GetAttribute("key");
if (!string.IsNullOrEmpty(valueToGet) && valueToGet == setting)
{
valueToGet = reader.GetAttribute("value");
return valueToGet;
}
}
}
}
return valueToGet;
}