Code in Global.asax prevents webpage from loading
Posted
by pete the pagan-gerbil
on Stack Overflow
See other posts from Stack Overflow
or by pete the pagan-gerbil
Published on 2010-04-23T10:00:51Z
Indexed on
2010/04/23
10:03 UTC
Read the original article
Hit count: 273
I've made a static class to hold a number of configuration values (and also swap these values out in unit tests).
If I initialise it in the Global.asax, the code runs correctly but the page doesn't load at all, and trying to navigate to a specific page fails.
I can't initialise the values in a constructor or inline on the field declarations, because I need to be able to swap the values out in unit tests before the web.config is interrogated.
Basically, putting the one line "ConfigClass.SetValues()" in the Global.asax prevents the app from loading correctly (although, as I say, it runs the code fine) and removing it again makes the app load properly - but without the class values initialised.
As an aside, I'm sure I had this working correctly and being initialised in the Global.asax yesterday. I'm positive I didn't take any action to change or break it...
Does anyone have advice on how I might track down what's going on here? Was I mistaken that it worked before (always possible) and that I need to go back and redesign something?
© Stack Overflow or respective owner