[Mono-list] Reading application settings from web.config file
Andrus Moor
kobruleht2 at hot.ee
Sat Jun 6 09:22:50 EDT 2009
Marek,
> This was fixed for trunk sometime ago, look at this bug
> https://bugzilla.novell.com/show_bug.cgi?id=491531
>
> I've just backported it to the 2.4 branch (r135562)
Thank you.
I need to read appsettings from an other assembly which is called from main
web application (asmx web service).
I tried code below but got exception
web.config does not contain appsettings
since rootWebConfig1.AppSettings.Settings.Count is 0.
How to read application setting in web.config from assembly which is not
main application assembly?
Andrus.
public string Server
{
get
{
System.Configuration.Configuration rootWebConfig1 =
System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration("~");
// rootWebConfig1.FilePath points to correct file.
if (0 < rootWebConfig1.AppSettings.Settings.Count)
{
System.Configuration.KeyValueConfigurationElement
customSetting =
rootWebConfig1.AppSettings.Settings["Server"];
if (null != customSetting)
return customSetting.Value;
else
throw new ArgumentException("No Server application
string");
}
throw new ArgumentException("web.config does not contain
appsettings");
}}
More information about the Mono-list
mailing list