Wednesday, 28 August 2013

How to get a String value from web.config in MVC4

How to get a String value from web.config in MVC4

I want to get a logFilePath value which I gave by hardcode in to
appSettings. I am trying to reach the key value by
System.Configuration.Configuration rootWebConfig1 =
System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration(null);
System.Configuration.KeyValueConfigurationElement customSetting =
rootWebConfig1.AppSettings.Settings["azureLogUrl"]; string pathValue =
customSetting.Value;
but I am getting null reference exception . How can I get the value from
web.config file?

No comments:

Post a Comment