I want to Use Console.writeline in my Asp.net MVC 3 Project. i don't know how to do it. i also try using System.Diagnostics.Debug.WriteLine()
method but it also doesn't work. can any one suggest a solution for this

- 2,356
- 6
- 36
- 47
-
possible duplicate of [What's the equivelent of System.out.println() in C#/Silverlight?](http://stackoverflow.com/questions/5052509/whats-the-equivelent-of-system-out-println-in-c-silverlight) – Paul Sasik Jul 26 '12 at 11:50
3 Answers
Debug.WriteLine("My debug string here");
should do the trick. Check that your application is in debug not release:
If nothing is coming out on your debug window, right click your project. Select properties. On the left of the opened tab, click Build. There is a check-box "Define DEBUG constant", make sure it is clicked.
You most likely know how to set the debug information to show in the output window (Debug->Windows->Output):

- 2,574
- 1
- 22
- 25
What do you want to do specifically?
If you want to output some debug info into the console while your MVC site is running, then I recommend the following:
1) Use System.Diagnostics.Debug.WriteLine()
2) Start the website using Debug (F5 key default, I think..) - and check the Output tab in Visual Studio
This is what I do for a lot of MVC 3/4 apps and it works just fine.

- 8,277
- 3
- 33
- 49
-
Even when running the website in Debug mode from Visual Studio? Are you sure you are looking at the Output panel? – Anders Arpi Jul 26 '12 at 11:51
-
-
1right click your project, select properties. On the left of the opened tab, click Build. There is a check-box "Define DEBUG constant", make sure it is clicked. – Jacob Brewer Jun 18 '13 at 17:28
-
**F5** runs your site in **debug** mode, whereas **ctrl + F5** runs it in **build** mode, so why is there 2 options? because **debug** mode runs very slowly & you can't edit your files while running it. So I suggest you watch what you're doing rather then just blindly following whatever everyone is saying. – Web Developer Apr 13 '21 at 01:02
It's not a console application but a web one. Use internal visual studio debug and quick watches to see what's happening in your program right now. In most production needs you can use some popular logging tools (log4net for ex).

- 78
- 4