The Daily WTF
Follow
CodeSOD: The HTML Print Value
Matt inherited a codebase of poorly written VB .Net code from a previous cost-saving measure. The code featured a problematic pattern of generating HTML and storing it in a session variable. This HTML was then intended to be displayed on a separate print page via a client-side redirect. The function responsible for generating the HTML, GenerateHTMLOfItem, surprisingly did not accept parameters as the item ID was already stored in a session variable. The redirect mechanism itself was inefficient, causing the browser to make a new request for the print page. Microsoft documentation advises against the overload of Response.Redirect used, as it terminates the thread and negatively impacts performance. The recommended alternative involves passing false to the endResponse parameter and calling CompleteRequest. Faced with numerous issues, Matt prioritized other tasks, leaving this particular code snippet to be commented with a frustrated plea. Despite the inefficiencies, this practice was seemingly adopted by developers, further complicating the codebase.