zoukankan      html  css  js  c++  java
  • asp.net调试

    asp.net

    一、调试三板斧
    1、
    <system.web>
      <!--
                设置 compilation debug="true" 可将调试符号插入
                已编译的页面中。但由于这会
                影响性能,因此只在开发过程中将此值
                设置为 true。
            -->
      <compilation debug="true">
      </compilation>
      
      <!--
                如果在执行请求的过程中出现未处理的错误,
                则通过 <customErrors> 节可以配置相应的处理步骤。具体说来,
                开发人员通过该节可以配置
                要显示的 html 错误页
                以代替错误堆栈跟踪。

    2、        <customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
                <error statusCode="403" redirect="NoAccess.htm" />
                <error statusCode="404" redirect="FileNotFound.htm" />
            </customErrors>
            -->
    </system.web>

    3、
    <%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" Trace="true" %>

    Trace.warn("DSO的类型是"+DSO.GetType().ToString());//红色
    Trace.write("DSO的行数"+DSO.Tables[0].rows.count); //黑色

    二、asp.net中的跟踪和进程调试
    1、整个项目的调试
    在web.config中
    <trace enabled="true" />
    http://localhost/我的虚拟目录/trace.axd

    2、附加进程调试
    自带是webDev.WebServer.exe
    iis5.0 是 aspnet_wp.exe
    iis6.0 是 w3wp.exe


    三、调试javascript
    1、准备工作
    internet选项中,把“禁用脚本调试(Internet Explorer)”和“禁用脚本调试(其他)”勾取掉。
    或在iis启用客户端脚本调试。
    2、debugger;
    3、脚本资源管理器
    4、js文件

    四、Asp.net调试中的常见问题解答
    1、iis重新注册 aspnet_regiis.exe -i
    2、集成windows身份验证 在iis里,身份验证
    3、为web创建应用程序。

    五、采用日志辅助调试
    1、数据库日志
    2、系统事件日志
    3、文本日志

    系统事件日志
    1、web.config中
    <customErrors mode="On" defaultRedirect="GenericErrorPage.htm">
     <error statusCode="403" redirect="NoAccess.htm"/>
     <error statusCode="404" redirect="FileNotFound.htm"/>
    </customErrors>
    2、Global.asax中
    <%@ Import Namespace="System.Diagnostics" %>
     void Application_Error(object sender, EventArgs e)
        {
            //在出现未处理的错误时运行的代码
            Exception errorInfo = Server.GetLastError();
            string Message = "URL:" + Request.Path + errorInfo.ToString();
            string LogName = "MyCustomLog";
            if (!EventLog.SourceExists(LogName))
            {
                EventLog.CreateEventSource(LogName, "logforweb");
            }
            EventLog log = new EventLog();
            log.Source = LogName;
            log.WriteEntry(Message, EventLogEntryType.Error);
           
            ////------------------------------------------------
            //EventLog.DeleteEventSource(LogName);
            //EventLog.Delete("logforweb");

        }


    六、Debug类和Trace类
    侦听器"Listeners"
    DefaultTraceListener
    TextWriterTraceListerner
    EventLogTraceListener
    ConsoleTraceListener
    XmlWriteTraceListener
    DelimitedListTraceListener
    写到文本文件中
     protected void logtotxt(string message)
        {

            Console.WriteLine(message);
            Debug.Listeners.Add(new TextWriterTraceListener(@"c:\log.txt"));
            //同时可以增加多个Listener
            Debug.AutoFlush = true;
            Debug.WriteLine(System.DateTime.Now.ToString()+message);

        }

  • 相关阅读:
    git 修改文件内容
    centos 7 安装gitlab
    安装Git 创建版本库
    安装 jenkins
    LVS 之搭建
    113. Path Sum II
    112. Path Sum
    111. Minimum Depth of Binary Tree
    110. Balanced Binary Tree
    109.Convert sorted list to BST
  • 原文地址:https://www.cnblogs.com/iceberg2008/p/1338884.html
Copyright © 2011-2022 走看看