I am migrating a web service from WCF service to ASP.Net Web API. When I try to add the following section to web.config, I get a page with error "Internal Server Error" when I try to run the application locally
<appSettings>
<add key="Environment" value="production" />
<add key="CacheEnabled" value="true" />
</appSettings>
When I remove this section, the error goes away. Can you please tell me how to add appSettings to a Web API project?
The following can be a guide on how to do it, verify that your appSettings are inside configuration
<configuration>
<appSettings>
<add key="Key" value="Value"/>
</appSettings>
</configuration>
To get the values of the key from the application you can do
textBox1.Text = ConfigurationManager.AppSettings["Name"];
Your appSettings
needs to to into the Web.config under the configuration
element as per the MSDN docs:
<configuration>
<appSettings />
</configuration>
appSettings
tagOtherwise, you would need to pass on the exact error message.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With