Home > .net, Asp.net > ConfigurationManager v.s. WebConfigurationManager

ConfigurationManager v.s. WebConfigurationManager

Web application should use WebConfigurationManager whereas winform application should use ConfigurationManager.
Why?

  1. The WebConfigurationManager class has a GetWebApplicationSection method that the ConfigurationManager class does not have
  2. The OpenMappedExeConfiguration method of the ConfigurationManager is replaced with the OpenMappedWebConfiguration method of the WebConfigurationManager
  3. The OpenExeConfiguration method of the ConfigurationManager is replaced with the OpenWebConfiguration method of the WebConfigurationManager

How to use it?
To be able to use WebConfigurationManager , you need to add System.Web reference and use it like this System.Web.Configuration.WebConfigurationManager or adding appropriate using statement.

To be able to use ConfigurationManager, you need to add System.Configuration reference and use it like this System.Configuration.ConfigurationManager or adding appropriate using statement.

Advertisements
Categories: .net, Asp.net
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: