.NET Questions (CLOSED)

Questions and Answers on any aspect of .NET. Now closed.

This discussion group is now closed.

Have a question about .NET development? Try stackoverflow.com, a worldwide community of great developers asking and answering questions 24 hours a day.

The archives of .NET Questions contain years of Q&A. Even older .NET Questions are still online, too.

web.config appSettings

Are the app settings I specify in web.config stored in memory while the application is running or are they read from the hard disk every time I want to access one.

I'm wondering if I should worry about caching the values as I access them?

i.e. Is this necessary:

public Shared readonly property WebRequestURL() As String
            Dim temp As String = HttpContext.Current.Cache("webreqeusturl")
            If temp Is Nothing Then
                'read it from web.config
                temp = System.Configuration.ConfigurationManager.AppSettings("webrequesturl")
                HttpContext.Current.Cache("webrequesturl) = temp
            End If

            Return temp
  end get   
end property

dan m Send private email
Wednesday, January 10, 2007
My understanding is that the config is read and parsed at startup and the reading of config values happens from an in-memory cache of the config file.  The application does not access (via disk IO) the file each time a value is requested.

You're use of the cache is somewhat redundant in that the file's contents are already cached.  So there's no need to do what you've proposed.

Hope that helps!!

Fevir Send private email
Wednesday, January 10, 2007
yeah that's what i was thinking... i'm just used to putting my config stuff from other sources in the cache.
dan m Send private email
Wednesday, January 10, 2007
If this weren't the case, wouldn't you want the read to happen once per application instead of once per session?  Somehting like:
Sub Application_OnStart
  Application("MyVar") = ...
End Sub

Friday, January 26, 2007

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics
Powered by FogBugz