Logo
programming4us
programming4us
programming4us
programming4us
Home
programming4us
XP
programming4us
Windows Vista
programming4us
Windows 7
programming4us
Windows Azure
programming4us
Windows Server
programming4us
Windows Phone
 
Windows XP

Microsoft ASP.NET 4 : Diagnostics and Debugging - Debugging with Visual Studio

- Free product key for windows 10
- Free Product Key for Microsoft office 365
- Malwarebytes Premium 3.7.1 Serial Keys (LifeTime) 2019
6/30/2011 9:29:21 AM
The tracing support built into ASP.NET works really well and is a great way to debug your application—especially once it is deployed. However, when you're in development mode, having to plant tracing messages in your page and then run it to see what happens is cumbersome and sometimes not the most efficient way of debugging. Microsoft Visual Studio provides excellent debugging support through the environment, and you can use it to watch your code execute and to step through the code one line at a time. In fact, you have access to all of the Visual Studio debugging facilities, even though you're developing Web applications.

Remember, ASP.NET and Visual Studio work in concert to make you feel like you're doing desktop application development, even though you are developing Web applications. That goes for the debugger as well. The following exercise familiarizes you with the Visual Studio debugging environment.

Debugging an application

  1. Open the DebugORama Web site. To support debugging, web.config needs to include the correct setting. You can type the debugger setting manually if you wish; however, Visual Studio will insert it for you once you start debugging.

    <system.web>
    <compilation debug="true"/>
    </system.web>

  2. Open the TraceMe.aspx page and insert breakpoints in Page_Load, AssembleTable, and Button1_Click. You can insert breakpoints by highlighting a line in the editor window and pressing the F9 key. You can also click Debug, Toggle Breakpoint on the main menu or simply click the light gray ribbon to the left of the text in the code editor (where the breakpoints are indicated). Visual Studio will show a big red dot to the left of the breakpoint lines, as shown in the following graphic:



  3. Start debugging by pressing the F5 key. You can also debug by clicking Debug, Start Debugging on the main menu. If debugging is not turned on in the web.config file, Visual Studio will ask you before it sets the debugging attribute. Visual Studio will start running the site. When it comes to your breakpoints, Visual Studio will stop execution and highlight the current line in yellow in the window, as shown here:



  4. In this example, Page_Load is the first breakpoint Visual Studio encounters. At this point, you can start stepping through the code. Press F10 to step overmethods, and press F11 to step into methods. Alternatively, you can click Debug, Step Over and Debug, Step Into on the main menu or use the corresponding toolbar buttons.

  5. Rest the mouse pointer on any variables you see. Notice how Visual Studio displays the value of the variable in a tooltip.

  6. Press F5 to resume the program. Visual Studio runs until it hits another breakpoint. Run through all the breakpoints.

  7. Next, post back to the server using the button. Notice the breakpoints are hit again. Also notice that first the Page_Load is hit, and then the Button_Click handler. This highlights the ephemeral nature of a Web page. A new page is being created for each request that comes in.

  8. Finally, try out a couple of the debug windows. You can monitor various aspects of your program by clicking Debug, Window on the main menu and selecting the window. Here is the Locals window, showing those variables in local scope:



  9. The Call Stack window, as depicted in the following graphic, shows how execution finally arrives at this spot. You can trace through and follow the entire program execution up to this point.



    Other notable windows include the Watch window, where you can examine any variable you want, and the Threads window, where you can see how many threads are running, what their thread IDs are, and so forth.

Other -----------------
- Microsoft ASP.NET 4 : Diagnostics and Debugging - Application Tracing
- Microsoft ASP.NET 4 : Diagnostics and Debugging - Page Tracing
- Microsoft ASP.NET 4 : Caching and State Management - The Wizard Control: An Alternative to Session State
- Microsoft ASP.NET 4 : Caching and State Management - Tracking Session State
- Microsoft ASP.NET 4 : Caching and State Management - Configuring Session State
- Microsoft ASP.NET 4 : Caching and State Management - Session State and More Complex Data
- Microsoft ASP.NET 4 : Caching and State Management - Introduction to Session State
- Installing and Configuring a Modem : Modifying the Modem’s Advanced Properties
- Installing and Configuring a Modem : Modifying the Modem’s General Properties
- Installing and Configuring a Modem : Working with Different Dialing Locations
 
 
Top 10
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 2) - Wireframes,Legends
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 1) - Swimlanes
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Formatting and sizing lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Adding shapes to lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Sizing containers
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 3) - The Other Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 2) - The Data Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 1) - The Format Properties of a Control
- Microsoft Access 2010 : Form Properties and Why Should You Use Them - Working with the Properties Window
- Microsoft Visio 2013 : Using the Organization Chart Wizard with new data
 
programming4us
Windows Vista
programming4us
Windows 7
programming4us
Windows Azure
programming4us
Windows Server