Our Black Friday Sale has been extended!  View Sale


Overlapping colored triangles

I just finished banging my head against the wall for many hours tracking down an obscure problem using OpenWebConfiguration() with custom ConfigSection's that use OnDeserializeUnrecognizedAttribute(). Although I'm still not sure why, the following is incorrect:

Configuration configuration = WebConfigurationManager.OpenWebConfiguration("~/web.config");

Instead, you need to use:

Configuration configuration = WebConfigurationManager.OpenWebConfiguration( HttpContext.Current.Request.ApplicationPath);

The first one seems to work, but your ConfigurationElement loses the values of any properties set by OnDeserializeUnrecognizedAttribute(). For some reason, your constructor for your ConfigurationElement's get called twice.
It's all the more frustrating because the Windows Service / Console Application version OpenExeConfiguration() worked correctly!

About the Author:



VisionFriendly.com is a Chicago digital marketing agency with over 25 years of experience helping clients nationwide. We have an in-house team of marketers and creatives ready to improve your business’s marketing operations.

Share On:


Leave a Comment

Your email address will not be published. Required fields are marked *

Copyright © 2024, All Rights Reserved
Tri Colored Triangles
Scroll to Top

We’re Doing Something Awesome

VisionFriendly.com is now Blackbird Digital.

We are the same great people, with a new name, new website, and new ideas.

Take your business to the

Next Level!

Visionfriendly.com has the right team to make your business stand out from other professional websites.

Ready For Takeoff?

A Completely Customized
Digital Marketing Experience

  • We'll be in touch within one business day to discuss your goals and create a personalized plan that fits both you and your business.

  • This field is for validation purposes and should be left unchanged.

Let’s start a Conversation