I have a live web application that is failing in one specific scenario, and locally it works fine. I don’t have remote debugging setup, and I want to check the value of some of the variables in the code. What would be the fastest way for me to log/email/debug the code to view those values?
Just to be clear, there is no error/exception being thrown. Something is different, and its causing the application to give unexpected results.
Thanks in advance!
The fastest way is to simply implement some logging in the Application_Error event within your Global.asax file. If you do not have a Global.asax file, simply create one with the VS New File wizard and it’ll handle that event for you.
It won’t help you get to local variables at the scope of the error, but you can log global variables from there and at least get some feedback on what the error is.
EDIT: In response to your comment, I recommend you output your Trace data to a file that you can analyze. I haven’t tried this myself, but I’ve seen it recommended. To your web.config, add something called a TraceListener like so:
You’re going to need to play around with it locally, I’m sure. For instance, make sure the trace is not visible to the client (this may involve using the Trace class to turn the trace on or off, and changing the streams it writes to).