Search code examples
vb.netapiweb-configapplication-settings

web.config: How do I read an integer value?


I am making an api and I want to read from the web.config an integer value. I tried to do it like this:

<applicationSettings>
    <HHH.Properties.Settings>
        <setting name="loggerPath" serializeAs="String">
        <value>Logs</value>
        </setting>
        <setting name="querytime" serializeAs="String"> 
            <value>30</value>
        </setting>
        <setting name="windowstime" serializeAs="String"> 
            <value>86400</value>
        </setting>
        <setting name="alarmarmingtime" serializeAs="String">
            <value>300</value>
        </setting>
    </HHH.Properties.Settings>
</applicationSettings>

The value I want to read is the windowstime but it throws me an error.

In the serializeAs property I cannot choose "integer" for example because it is an enumerated one and it does not have this option. How should I do it?


Solution

  • I already resolved it. I used this:

      <appSettings>
        <add key="webpages:Version" value="3.0.0.0" />
        <add key="webpages:Enabled" value="false" />
        <add key="ClientValidationEnabled" value="true" />
        <add key="UnobtrusiveJavaScriptEnabled" value="true" />
        <add key="windowstime" value="86400"/>
      </appSettings>