Handling invalid values ​​in web.config

If the entry in the web.config file is an invalid value, I should throw an exception or set its default value when I read it from my application.

For example:

 <add key="enablePasswordReset" value="Invalid">

If my application reads this and wants to save it in the Boolean property, should I throw an exception or set its default value to "true"?

+3
source share
4 answers

Getting the right configuration is so important that I would throw it away Exceptionif it was dodgy at all ... it is better to detect a configuration error as soon as it is done.

  • "a": ; YSOD, , ,
  • "b": ; , , - " 0" , , dev
  • "c": ; , , , , ; /...

"a" ...

+6

. , , . ... ( ) . , .

+3

;)

-, ? , , .

, - , - .

web.config - .

+1

If I did this, I would just use reset to the default value, although this could lead to incorrect hidden errors in the string if parsing or save code was broken.

0
source

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


All Articles