Could any one of you please help me out in finding the root cause for an issue that I faced very recently. The issue is explained below:
I have a web application. And in the web.config for this application I have included a key called "idpssourl" and assigned it a value. Now I am adding a class library(dll) reference in this web application. In that dll I am trying to read the value for "idpssourl"
using the below statement:
WebConfigurationManager.AppSettings["idpssourl"]
This was working fine sometimes. But very often the statement returns a NULL value and because of that when I try to load a page, I got HTTP 403 forbidden error.
I changed the above statement as below:
ConfigurationManager.AppSettings["idpssourl"]
and the issue got solved. Any idea on why this happened? It would be helpful for me if I find the root cause. I spent almost a weeks time in getting this issue fixed.
The WebConfigurationManager provides access to be able to edit the web.config file at design time, where as ConfigurationManager is generally just read-only.
Also its worth noting that using the WebConfigurationManager generally requires higher permissions due to it requesting Write Access, and not just Read Access. This is sometimes an issue developers come accross that can make it fail.
Scott was here...
Marked as answer by satajl on Feb 02, 2012 05:58 PM
@N_EvilScott...Buddy...I completely agree with you as that was my thought too. We can finalize that this was the root cause unless and until we find some other member coming out with a different explanation. Thanks buddy :)
satajl
Member
3 Points
11 Posts
Issue with WebConfigurationManager
Feb 01, 2012 11:38 PM|LINK
Hey guys,
Could any one of you please help me out in finding the root cause for an issue that I faced very recently. The issue is explained below:
I have a web application. And in the web.config for this application I have included a key called "idpssourl" and assigned it a value. Now I am adding a class library(dll) reference in this web application. In that dll I am trying to read the value for "idpssourl" using the below statement:
WebConfigurationManager.AppSettings["idpssourl"]
This was working fine sometimes. But very often the statement returns a NULL value and because of that when I try to load a page, I got HTTP 403 forbidden error.
I changed the above statement as below:
ConfigurationManager.AppSettings["idpssourl"]
and the issue got solved. Any idea on why this happened? It would be helpful for me if I find the root cause. I spent almost a weeks time in getting this issue fixed.
N_EvilScott
Star
8303 Points
1488 Posts
Re: Issue with WebConfigurationManager
Feb 01, 2012 11:53 PM|LINK
The WebConfigurationManager provides access to be able to edit the web.config file at design time, where as ConfigurationManager is generally just read-only.
Also its worth noting that using the WebConfigurationManager generally requires higher permissions due to it requesting Write Access, and not just Read Access. This is sometimes an issue developers come accross that can make it fail.
satajl
Member
3 Points
11 Posts
Re: Issue with WebConfigurationManager
Feb 02, 2012 06:01 PM|LINK
@N_EvilScott...Buddy...I completely agree with you as that was my thought too. We can finalize that this was the root cause unless and until we find some other member coming out with a different explanation. Thanks buddy :)