Common Development debugging skills

Source: Internet
Author: User

1. Set breakpoints and track debugging

Press the F9 key at the place where the breakpoint is required. Press F9 for each process and press F11 for each statement. CTRL + Shift + F9 delete all breakpoints.

A conditional breakpoint can be set to hit a breakpoint when a certain condition is met.

2. Page tracking

Add trace = "true" at the top of the page to start the tracing on this page.. The tracemode = "sortbycategory" command can be added to sort by category.

Front-end code

 <%  @ Page trace =  "  True  "  Language  =  "  C #  "  Autoeventwireup  =  " True  "  Codebehind  =  "  Default. aspx. CS  "  Inherits  =  "  _ 21. _ default  "  %> 

<! Doctype HTML public "-// W3C // dtd xhtml 1.0 transitional // en" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" >

< Html Xmlns = "Http://www.w3.org/1999/xhtml" >
< Head Runat = "Server" >
< Title > </ Title >
</ Head >
< Body >
< Form ID = "Form1" Runat = "Server" >
< Div >

</ Div >
</ Form >
</ Body >
</ Html >
 
Using system;
Using system. Collections. Generic;
Using system. LINQ;
Using system. Web;
Using system. Web. UI;
Using system. Web. UI. webcontrols;

Namespace _ 21
{
Public partial class _ default: system. Web. UI. Page
{
Protected void page_load (Object sender, eventargs E)
{
String Strid = request. Params ["ID"];
Trace. Write ("page_load", "Strid value:" + Strid );
Trace. Warn ("Page warning", "pageload executed ");

}
}
}

We found that in addition to the normal information, a bunch of debugging information is added at the bottom of the page.

The following describes the custom page tracking information.

You can use the trace. Write and trace. Warm methods to add the desired trace information to the page trace information.

Of course, you do not have to enable tracking through page settings, or you can use CSCodeTrace. isenable in.

3. debug client scripts

In Asp.net development, the script can improve BS Program Ability to interact with customers and reduce data transmission between clients and services.
However, most Asp.net developers tend to avoid writing client scripts or simply using scripts to complete some simple functions,
There are many reasons for this, but it is difficult to debug the script program.
The following procedure describes how to use the debugger in vs.net to debug javascript:
1. First, you need to allow your IE to debug the script. The specific steps are as follows:
Choose IE> tool menu> inter option> Advanced Tab> disable script debugging.
2. Open vs.net and create a new Asp.net project (or open a project)
3. Run the page you want to debug
4. When your page is displayed in IE, return to vs.net again.
5. Set the breakpoint in the script:
Debug menu-> window-> debug document
-> Select the page to debug in the "Running document" (this is a floating toolbar similar to solution Manager)
6. Then, you can access the script through webpage operations. When the script runs to a breakpoint, You can debug it.
If you want to enter the debugging status when loading the page, you can press F10 (process by process) for debugging.

 

 

4. Application-level tracking

Application-level tracing allows you to view the tracing of the entire application. You do not need to set trace = true for each page, but it collects the tracing information for each request page,

The user does not see any content.

First, set web. config and add the <trace enable = "true"/> configuration.

<Configuration>

<System. Web>

<TraceEnabled= "True"/>

</System. Web>

</Configuration>

You can useRoot directory/trace. axdTo view the trace information.

This file does not actually exist. It is a special URL intercepted by Asp.net and will provide a list of requests.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.