How to enable debugging in an ASP.NET Application?

Sheonarayan
Posted by in ASP.NET category on for Intermediate level | Points: 250 | Views : 17764 red flag

Bug is unavoidable in application at the time of development. Debugging helps us to find out bugs and error in the program. In this article, we shall learn how to enable debugging in an ASP.NET application.

Introduction

Debugging refers to a process in the software development to find out bugs, errors in the program at
development stage.


In order to demonstrate, how to enable debugging in an asp.net application I am going to show important code changes needs to be done in asp.net application.

 
WEB.CONFIG

<system.web>

<compilation debug="true" targetFramework="4.0" />

</system.web> 

By default web.config has compilation debug=false that restricts the application to run into the debug mode. Changing it to true allows the application to write the debug statements in the Output window. These statements can be anything that helps the developer to know what exactly is going on while executing the program in the development stage.

To use the Debug class, we need to use System.Diagnostics namespace. 
Watch the video of this topic below

 
Get video tutorials of hundreds of ASP.NET Tips and Tricks like this here.

Code Behind

Namespace to use

using System.Diagnostics;
 

protected void Page_Load(object sender, EventArgs e)

{

Debug.WriteLine("START - Page_Load executing");

txtSample.Text = "Some data";

Debug.WriteLine("END - Page_Load executing");

}

The Debug statement can be seen in the Output window (Debug > Windows > Output).

OUTPUT

Notice the last two statements in the above window that is being written because of Debug.WriteLine statements in the Page_Load event.

Hope this article was useful, thanks for reading and keep reading & sharing !

Page copy protected against web site content infringement by Copyscape

About the Author

Sheonarayan
Full Name: Sheo Narayan
Member Level: HonoraryPlatinum
Member Status: Administrator
Member Since: 7/8/2008 6:32:14 PM
Country: India
Regards, Sheo Narayan http://www.dotnetfunda.com

Ex-Microsoft MVP, Author, Writer, Mentor & architecting applications since year 2001. Connect me on http://www.facebook.com/sheo.narayan | https://twitter.com/sheonarayan | http://www.linkedin.com/in/sheonarayan

Login to vote for this post.

Comments or Responses

Posted by: Tripati_tutu on: 6/29/2011 | Points: 25
Nice one sir ...
Posted by: Lakn2 on: 6/29/2011 | Points: 25
good one
Posted by: Akiii on: 7/3/2011 | Points: 25
nice article sir....

Regards
Akiii

Login to post response

Comment using Facebook(Author doesn't get notification)