So my patience is running out. The web application I inherited when I started here is throwing exceptions in all the places in the code that I said from the outset were not fit for production. Today's error:
"Value cannot be null", accompanied by some Linq to Xml related stacktrace. No logs.
What does the page in question do?
It displays protocolled information for scheduled jobs.
How does it do it?
It loads a load of data from a Webservice. This data contains Xml in a text field which comes from a database. This Xml string is then loaded into an XDocument which is then transformed and the result looped over to fill up some html table layout that is built in codebehind, from a HTML-esque xml file that again has to be looped over to create the table. There is no markup in the entire page. Then the log information is also loaded using the same webservice which also gets looped over, turned into an XDocument (basically parsed in by hand). This then also gets transformed and rendered in the same manner. Then the webservice gets called again and the user information gets loaded. This is then parsed by hand into a Dictionary<string, string> and gets databound to a detailsview which has somewhere in the codebehind been added to the control tree. The best bit is the fact that the original database Xml later gets deserialized to it's respective type and is subsequently displayed as Xml in another tab by calling a .ToString() override on that type.
Each page lifecycle event handler has something like this:
this.PreRender += new EventHandler(JobDetail_PreRender);
Despite the fact that page lifecycle events are integral to webforms and you don't need to, and in fact shouldn't really do this. Maybe there's an edge case somewhere where it is justified, assuming that the developer knows what they're doing. Based on the general impression of the code produced to solve a simple and trivial problem, I can't make that assumption.
+= new EventHandler
When I wrote web forms, I'd also use
<%@Page %>header. Then I'd need to manually setup events like
I probably did it to avoid errors like typos in the event name which cause it not to be called without me noticing anything or something. I honestly can't remember any more - it was many years ago.