I'm trying to see the output of a foreach loop in my code in the output window in an ASP.NET web app, but I don't get any results even though there is valid data. I've done a fair amount searching using Google with this issue, but nothing I've done works. Here is the code in my ASPX page:
List<MyClass> myClasses = GetMyClasses();
foreach (MyClass myClass in myClasses)
{
Debug.WriteLine(myClass.SomeProperty);
}
The code is very straight-forward. When I debug this page, myClass.SomeProperty has the value I want, but nothing is getting printed to the output window. What could I be missing? I cannot use a Response.Write because my Response stream is being used to create an Excel file. I also don't want to use Tracing.
I have this in my web.config file:
<system.web>
...
<compilation debug="true" targetFramework="4.0">
...
</system.web>
(Sorry no full answer, but a bit long for a comment)
There are debug related features. (Related What does the optimize switch do)
What you need for your problem is the DEBUG
conditional. I guess the debug="true"
switch affects only the debug symbols but not the conditional.
edit:
hmm strange. scottgu states at http://weblogs.asp.net/scottgu/archive/2005/11/06/429723.aspx that debug="true"
should affect that conditional.
Note that the value of debug in a web app is driven by the value of the value in your web.config file.
You are using System.Diagnostics.Trace, rather than the ASP.NET Tracing. To get System.Diagnostics.Trace working within ASP.NET see http://msdn.microsoft.com/en-us/library/b0ectfxd(v=vs.85).aspx.
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