How to use Console.WriteLine in ASP.NET (C#) during debug?

后端 未结 7 786
误落风尘
误落风尘 2020-12-22 21:51

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:



        
相关标签:
7条回答
  • 2020-12-22 22:26

    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.

    0 讨论(0)
提交回复
热议问题