Thursday 15 May 2014

configuration - ASP.NET does not attempt to open web.config file? -



configuration - ASP.NET does not attempt to open web.config file? -

i trying .aspx page read web.config file. code works on other servers not work expected on 1 particular server (all machines involved w2k3 r2 sp2).

a snippet of .aspx

<body> <form id="form1" runat="server"> <div> <asp:label runat="server" text="" id="lbltime" /><br /> value of myconfigtest '<asp:label id="lblvalue" runat="server" text=""/>' </div> </form> </body>

the code here:

using system; using system.web.configuration; namespace configtestweb { public partial class _default : system.web.ui.page { protected void page_load(object sender, eventargs e) { lbltime.text = datetime.now.tolongtimestring(); string value = webconfigurationmanager.appsettings["myconfigtest"]; lblvalue.text = value; } } }

and web.config file set thusly:

<?xml version="1.0"?> <configuration> <appsettings> <add key="myconfigtest" value="this test"/> </appsettings> <system.web> <compilation debug="true" targetframework="4.0" /> </system.web> </configuration>

in effort troubleshoot setup procmon filter on web.config , nail page browser. output

1:06:04 pm value of myconfigtest ''

but unusual thing procmon never reports effort access file! if right-click on virtual directory in iis , select properties | asp.net | edit configuration can see web.config beingness accessed ~65 entries in procmon, , appsetting reported correctly in asp.net configuration settings dialog.

i believe i've ruled out acl's issue by a) setting entire directory tree .aspx , web.config in | total permissions b) procmon study failed attempts open file if permissions issue

in desperation uninstalled / reinstalled asp.net 4.0.

it may noteworthy reading configuration .exe works on server using

string value = system.configuration.configurationmanager.appsettings[key];

this issue appears across multiple virtual directories.

so question is, might preventing 1 server beingness able read web.config files?

rather going problem of using procmon seek doing simpler test: edit web.config file enable trace feature, access website , see if shows request trace.

add web.config within of system.web node:

<trace enabled="true" requestlimit="10" pageoutput="false" tracemode="sortbytime" localonly="false" />

by default changes web.config (when file saved/written disk) restart asp.net application pool. these options can changed, however, if not see alter in web app behavior after modifying web.config can seek stop , restart service, or trigger app pool recycle using task manager kill aspnet_wp.exe process (i think called in 2k3, if not seek w3wp.exe instead), create request (refresh browser) web app , iis should start app pool ya.

if changes (toggling between trace enabled=true , enabled=false) not visible after saving web.config, visible after forcing stop/restart, iis on box may not have alternative restart app pool when configuration changes (don't have 2k3 in front end of me, in iis 7 under application pools > advanced options > recycling > "disable recyling configuration changes" -- 1 of annoying double-negative options, "false" means recycle after config changes, , "true" means don't).

update: dang, looks iis6 doesn't have "for configuration changes" alternative in recycling tab of app pool properties sheet. sorry, not sure setting stored, doesn't appear in machine.config or web.config tho, whatever iis uses internally metabase stuff (registry maybe?)

if seek trick toggling trace , don't see effects, did verify editing right web.config file?

asp.net configuration

No comments:

Post a Comment