AppSettings vs options for a specific project in Web.Config

Okay, so this one confused me a bit. I have the following:

string csvOfAttributes = CableSolve.Web.Properties.Settings.Default.GenerateBoothReportAttributes;

and in my web.config:

<CableSolve.Web.Properties.Settings>
  <setting name="GenerateBoothReportAttributes" serializeAs="String">
    <value>327, 329, 330, 369, 342</value>
  </setting>
</CableSolve.Web.Properties.Settings>

I have two questions:

  • If I omit the settings from the web.config file, I get compilation errors. How is this possible? Web.config is user editable; I would only expect runtime errors. If I compile my application, expand it, then the user will edit the name of this parameter - will the compiled code violate?
  • I could save this parameter in the appConfig section of my web.config file. To access the values โ€‹โ€‹that I could go through the ConfigurationManager, and I would only get a null object at runtime if this parameter is missing. This seems less beneficial since I prefer my errors that occur during compilation, but I wonder: what are the differences between the two options and when should I use them?
+3
source share
1 answer

, : - , . , . , , .NET "", Javascript: , . :

  • ,
  • , .
  • ""
0

All Articles