How to find out a parameter value from a web.config file in an ASP.NET application?

I am trying to use the following command:

Dim xmlFilePath As String = _
    System.Configuration.ConfigurationManager.AppSettings("XmlFilePath")

to get the following setting:

<applicationSettings>
    <MySolution.WebProject.My.MySettings>
        <setting name="XmlFilePath" serializeAs="String">
            <value>C:\ASP.NET\Folder\MessageLog</value>
        </setting>
    </MySolution.WebProject.My.MySettings>
</applicationSettings>

However, it xmlFilePathappears as Nothingafter the execution of this line of code.

What is the correct code to get the setting from the web.config file in an ASP.NET application?

NOTE. Although you can add keys separately to a tag <appsettings>, I'm trying to figure out how to use it with the Settings tab in the project properties.

+3
source share
2 answers

Take a look

My.MySettings.Default.XmlFilePath
+4
source

Usually I see how it is done differently.

<appSettings>
    <add key="XmlFilePath" value="C:\yourpath here" />
</appSettings>

, "ConfigurationManager".

+4

Source: https://habr.com/ru/post/1760410/


All Articles