How do you debug web applications written in C# in Visual Studio? I'm using Console.WriteLine expecting the text to appear in the Output tab. Like it does when you develop console applications. But for web applications, the console output doesn't show up anywhere.
Asked
Active
Viewed 2.7k times
20
-
1This will be shown in browser's console. Install FireBug in FF and you can see the console output. You can also see the console output in Safari and Chrome in their buit-in error console. – fardjad May 10 '11 at 11:56
-
2Check out this question; http://stackoverflow.com/questions/137660/where-does-console-writeline-go-in-asp-net – Chris McAtackney May 10 '11 at 11:57
-
@fardjad: Console.WriteLine shows up in browser's console? Really? – spender May 10 '11 at 11:58
-
@spender: I thought Console.WriteLine is similar to console.log in javascript. I'm sorry for my mistake. – fardjad May 10 '11 at 12:05
2 Answers
26
Debug.WriteLine

spender
- 117,338
- 33
- 229
- 351
-
are you attached to the web process? ie, have you run the web site, or have you manually attached to w3wp? – dnolan May 13 '11 at 16:13
-
It works when I run the app in debug mode in visual studio, but not otherwise. I guess doing that is a solution, but debug mode turns on lots of other "features" i dont want and is annoying to use. – Björn Lindqvist May 16 '11 at 21:38
-
Create your own logging functionality then, or use `Trace.WriteLine`. – Mathias Lykkegaard Lorenzen Feb 11 '14 at 12:38
2
They are two form to write in Console Output for NET applications.
Debug.WriteLine() // See [Microsoft Documentation][1]
Trace.WriteLine() // See [Microsoft][2] documentation for more information
The difference between the two is that Debug only work when the program is in DEBUG mode. In the other hand TRACE works always. You can also set different levels of TRACE. See documentation for more information.
I hope that this information help you.

freedeveloper
- 3,670
- 34
- 39