Is reading app.config expensive?

I’m sure that all configuration files(web.config or app.config) are cached by default, so you don’t need to create a static class that holds all values or be afraid that the files are accessed permanently.

Here is some reading:

  • Web.Config is Cached
  • ConfigurationManager.RefreshSection Method
  • Application Configuration Files Explained
  • ASP.NET Configuration Overview

Regarding to your requirement to access another application’s config file:

MSDN: “These methods(note: for client applications: ConfigurationManager.GetSection) provide access to the cached configuration values for the current application, which has better performance than the Configuration class.”

In other words: Yes, you should cache it when it’s not your own app’s config file.

Leave a Comment

tech