I want to write some result to the console in ASP.NET (C#). It works in a Window application, but a Web application does not work. Here is what I have tried:
protected void btonClick_Click(object sender, EventArgs e) { Console.WriteLine("You click me ..................."); System.Diagnostics.Debug.WriteLine("You click me .................."); System.Diagnostics.Trace.WriteLine("You click me .................."); }
But I see nothing in the Output panel. How do I solve this problem?
WriteLine(String, Object, Object) Writes the text representation of the specified objects, followed by the current line terminator, to the standard output stream using the specified format information.
It goes to the console (standard output) or to the stream that the console is set to.
You can use Debug. Writeline("debug information") . It will be displayed in the Output window.
The C# readline method is mainly used to read the complete string until the user presses the Enter key or a newline character is found. Using this method, each line from the standard data input stream can be read. It is also used to pause the console so that the user can take a look at the output.
Console.Write will not work in ASP.NET as it is called using the browser. Use Response.Write instead.
See Stack Overflow question Where does Console.WriteLine go in ASP.NET?.
If you want to write something to Output window during debugging, you can use
System.Diagnostics.Debug.WriteLine("SomeText");
but this will work only during debug.
See Stack Overflow question Debug.WriteLine not working.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With