Question App.config?

raysefo

Well-known member
Joined
Jul 21, 2010
Messages
207
Programming Experience
Beginner
Hi,

I want to use App.config file in order to get some values without recompiling. I created App.config on root of my project. I try to read values from App.config but it brings nothing. How can i read value from App.config?

App.config.xml
VB.NET:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <appSettings>
    <add key="result1" value="0" />
    <add key="result2" value="1" />
    <add key="result3" value="2" />
  </appSettings>
</configuration>

Here is code part:
VB.NET:
 Try
          
            Dim num As String = ConfigurationManager.AppSettings("result1")
            Response.Write(num)
        Catch ex As Exception
            Console.WriteLine(ex.Message)
        End Try
 
I did some googling and noticed that web.config file is for web sites (ASP.NET), so adding appSettings to web.config has any drawbacks?

thanks in advance
 
Back
Top