Forums: Conditional display of debugging info - Forums

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Conditional display of debugging info

#1 User is offline   Pete K 

  • Advanced Member
  • PipPipPip
  • Group: Members
  • Posts: 247
  • Joined: 05-February 16
  • Gender:Male

Posted 13 October 2017 - 12:36 PM

You may already know that you can display SQL statements and/or all session variables in your pages for debugging purposes by adding code to the "After application initialized" event. But, like me, you may find yourself activating/deactivating that code during the development cycle, with each change requiring a re-compile. I have started adding the following code to every app I work on at the very start. It only displays the debugging information if you include specific querystrings in your request: debugSQL=true and/or debug=true. This way I can leave the code in without the debug info getting in the way when I don't need it. Remember to de-activate before production deploy.

Here's the code:

// Displays SQL statements if debugSQL=true
if (MVCFunctions.postvalue("debugSQL") == "true") 
		GlobalVars.dDebug = true; 

// Displays all session vars if debug=true
if (MVCFunctions.postvalue("debug") == "true") 
		for (int i = 0; i < HttpContext.Current.Session.Count; i++)
			var crntSession = HttpContext.Current.Session.Keys[i];
			HttpContext.Current.Response.Write(string.Concat(crntSession, "=", HttpContext.Current.Session[crntSession]) + "

I hope this is helpful. Please share your tips as well!

Pete K.
Lead Web Developer
Fayette County Public Schools | Lexington, Kentucky, USA

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users