私のweb.config
ファイルには
<appSettings>
<add key="Service1URL1" value="http://managementService.svc/"/>
<add key="Service1URL2" value="http://ManagementsettingsService.svc/HostInstances"/>
....lots of keys like above
</appSettings>
で始まるキーの値を取得し、その値をC#クラスにService1URL
渡したい。string[] repositoryUrls = { ... }
どうすればこれを達成できますか?
私はこのようなことを試みましたが、値を取得できませんでした:
foreach (string key in ConfigurationManager.AppSettings)
{
if (key.StartsWith("Service1URL"))
{
string value = ConfigurationManager.AppSettings[key];
}
string[] repositoryUrls = { value };
}
私はそれを間違った方法でやっているか、ここで何かを逃しています。どんな助けでも本当にありがたいです。