How does the application start, how are the values โ€‹โ€‹read from web.config?

I'm curious how web.config is loaded into the application, is there any link to the values โ€‹โ€‹in the web.config file, actually parsing the web.config file, or when the application starts, it loads the values โ€‹โ€‹into a singleton or something

This seemed to me because I wanted to check the value in the web.config file for each request in the global.asax.cs file:

protected void Application_BeginRequest(object sender, EventArgs e) { if( ConfigurationManager.AppSettings["abc"] != null) { } } 
+6
source share
2 answers

When the application first receives the request, the configuration file (s) receives parsing and its settings are loaded. These settings are then cached, so any subsequent call does not require re-analysis of the configuration file (s). That is why when changing the configuration file, the application restarts and recompiles again.

http://msdn.microsoft.com/en-us/library/ms178685.aspx#calculating_configuration_settings_at_runtime

+4
source

The configuration is deserialized at application startup time into the appropriate ConfigurationSection types.

Usually they are implemented with read-only properties, so they can be used in single mode.

+3
source