browser icon
You are using an insecure version of your web browser. Please update your browser!
Using an outdated browser makes your computer unsafe. For a safer, faster, more enjoyable user experience, please update your browser today or try a newer browser.

ASP.NET Console Debug Logging

Posted by on November 28, 2011

I ran into an unexpected thing today. I was trying to get a debug line to print in the output console in Visual Studio for an ASP.NET site I’m working on, and it didn’t make sense to me. I eventually figured it out, and decided to make a note of it because I know I will probably need it again, and also know that it might help someone else.

I had a variable at the data access level, and it didn’t seem like it was doing what I wanted. I added a simple
Console.WriteLine("ISERROR=" + Convert.ToString(variableNameHere));
but this didn’t display anything in the Visual Studio output window like I expected.

I then used this instead, and it worked great. There was my variable, with an unexpected value.
System.Diagnostics.Debug.WriteLine("ISERROR=" + Convert.ToString(variableNameHere));

ASP.NET Debug Window

That’s it. I hope this helps someone else out there.

-Adrian

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>