Easy Debugging in ASP.Net
to output text in a c# application (web or form)
Option #1:include:
using System.Diagnostics;
private void main()
{
functionName();
}
then outside of your functions
[Conditional("DEBUG")]
private void functionName()
{//this only displays when using debug compilation
Console.WriteLine("debugging text output");
}
Option #2:
protected void Page_Load(object sender, EventArgs e)
{
#if DEBUG
//only displays when web.config compilation debug="true"
Console.SetOut(Response.Output);
Console.WriteLine("WEBSITE IS IN DEBUG MODE!");
#endif
}
this is a good idea for web applications to remind you to disable debugging when you push a site to your production server.
Labels: asp.net

0 Comments:
Post a Comment
<< Home