Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.net why is application settings string only?

    <appSettings>
        <!-- Settings file for website! -->
        <add key="DefaultCookieExpiryMins" value="30" />
    </appSettings>

Why do I have to set everything as a string? Why can't I have different datatypes in there like int to help me stop having to cast everything?

like image 769
Tom Gullen Avatar asked Jan 23 '26 08:01

Tom Gullen


1 Answers

This is why I prefer custom configuration sections over just putting key/value pairs in appSettings. See this MSDN article for more information on how to make your own configuration section. Once you have your own configuration section class, you should be able to access your settings as any data type you'd like.

like image 162
Jacob Avatar answered Jan 25 '26 22:01

Jacob