How to load specific environment in web.config at run time without impacting the application life cycle in .net framework

Vikash Tripathi 1 Reputation point
2022-12-02T12:06:20.053+00:00

Hello guys,

How to load the environment specific web.config at run time. At build time we can't specify the environment as the same build output is used for all environments. Also, when trying to replace web.config in global.asax application_start() getting called every time. So please suggest an approach to load environment specific web.config at runtime?

Developer technologies | .NET | .NET Runtime
Developer technologies | ASP.NET | Other
{count} votes

1 answer

Sort by: Most helpful
  1. Bruce (SqlWork.com) 77,686 Reputation points Volunteer Moderator
    2022-12-02T22:56:53.42+00:00

    you should update the web.config on deployment.

    by design asp.net reloads the application on web.config changes. asp.net core does not have this restriction (well it does, but uses appsettings.json instead of web.config, which does not trigger a restart).

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.