Which part is executed first by asp.net core CLR, the configuration file or the Main() method.

bhavna 106 Reputation points
2022-02-13T12:20:36.277+00:00
  1. For .NET Framework which executes first web.config or global.asax?
  2. For .NET Core which executes first Main() or different available config files?
ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
4,238 questions
ASP.NET
ASP.NET
A set of technologies in the .NET Framework for building web applications and XML web services.
3,312 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Bruce (SqlWork.com) 57,886 Reputation points
    2022-02-13T16:51:18.61+00:00

    As stated we.config is just a file and not executed. It can be read many times and many different sections of code.

    With asp.net hosted by IIS, the first request to a application dir, the asp.net runtime will read the web.config, to configure the application. Once I the modules and handlers are loaded it will execute the pipeline. You asp.net code may read the web.config to get settings.

    With .net framework console apps, there is typically an app settings. Again this read to get configuration information by the hosting code, then may be read after main is called to application settings.

    With .net core reading the config files are optional. You add code to read them.

    0 comments No comments