SlideShare a Scribd company logo
1 of 37
   Setting up debugging
   Creating custom errors
   Debugging on a remote server
   Debugging client script
   Troubleshooting
   Monitoring a running ASP.NET site
   You can debug an ASP.NET application using the
    standard features of the Visual Studio debugger like
    setting breakpoints in code, to view variable values
    in watch windows, to step-through code inside the
    Integrated Development Environment (IDE), to
    extract error information, to execute code in the
    command window and the like.
   To do so, you must first configure ASP.NET for
    debugging.
   There are two areas where you can configure:
    1. the project’s property page and

    2. the Web.config file.
    The first step is to enable the ASP.NET debugger in
     your project’s Property Pages dialog box.

1.   Right-click the Web site in Solution Explorer to
     open the shortcut menu.
2.   Select Property Pages from the shortcut menu. This
     will open the Property Pages dialog box for the
     given Web site
3.   Select Start Options from the left side of the dialog
     box.
4.   In the Debuggers section, at the bottom of the
     dialog box, select (or clear) the ASP.NET check box
     to enable (or disable) the ASP.NET debugger for
     Visual Studio.
   The second step is to enable debugging either for
    your entire site or on a page-by-page basis.
   You enable debugging for your entire site through
    the Web.config file by setting the debug attribute of
    the compilation element to true.
    <configuration>
    <system.web>
    <compilation debug="true">
    </compilation>
    <system.web>
    </configuration>
   To enable page-level debugging, set the Debug
    attribute of the @ Page directive
    <%@ Page Debug="true" ... %>
    You do not want to show users the
     default, ASP.NET error page if your site happens to
     break.

    You most likely want users to see a page that
     instructs them on how they can contact support to
     resolve the problem.

    You can configure your site to display a generic
     error page if users happen to encounter an
     unhandled error.

1.   Can set this page at the site level.
2.   Can also set individual pages for specific error types
   You configure custom errors inside the Web.config file
    using the <customErrors> element nested inside
    <system.web>.
   This element has the attributes mode and defaultRedirect.

   The mode attribute can be set to on to turn custom errors
    on, off to turn them off, or RemoteOnlyto turn custom
    errors on for remote clients only.

   The defaultRedirect attribute is used to indicate the path to
    a default error page.
<configuration>
       <system.web>
       <customErrors defaultRedirect="SiteErrorPage.aspx"
       mode="RemoteOnly">
       </customErrors>
       <system.web>
       </configuration>
      On redirection, the server passes the path of the page that
       caused the error. This path is provided as part of the
       query string using the named parameter aspxErrorPath.


http://localhost/examples/SiteErrorPage.aspx?aspxerrorpath=/examples/Default.aspx
   It is also possible to define specific pages for various
    HTTP status codes.
   This allows you to provide more specific information to
    users when they hit a given status code.
   For example, if users do not have access to a given page or
    resource, they will be shown the HTTP error 403.
   This status code indicates they are denied access to the
    resource.
   You can then write a custom page that explains the
    process for obtaining access to a given resource.
   Use the <error> element to redirect to that custom page.
<configuration>
<system.web>
<customErrors defaultRedirect="SiteErrorPage.aspx"
   mode="RemoteOnly">
<error statusCode="403" redirect="RestrictedAccess.aspx" />
</customErrors>
<system.web>
</configuration>
   The process of enabling remote debugging is made
    easier through the Remote Debugging Monitor
    (Msvsmon.exe).
   You run this tool on the server you intend to debug.
   The tool can be found inside your development
    environment installation folder (for example, Program
    FilesMicrosoft Visual Studio 9.0Common7IDE
    Remote Debuggerx64).
   You can copy the .exe to a file share or over to the server.
   You can also install the tool from the Visual Studio DVD
    set.
   You begin a remote debugging session by opening
    Visual Studio and a solution that includes the code you
    intend to debug.

   You can then attach to the server running the Remote
    Debugging Monitor application from the Debug menu
    by selecting Attach To Process.

   This opens the Attach To Process dialog box.

   In this dialog box, you set the Qualifier to the name of
    the server running the Remote Debugging Monitor.
   The server name is set in the Options dialog box for the
    Remote Debugging Monitor and typically is defined as
    User@Server.

   You will then see a list of running processes on the
    server.

   Select the ASP.NET Web server process and click Attach
    to start remote debugging.

   Hit the server through a browser to cause a breakpoint to
    fire or an error to occur.

   Doing so will send you into debug mode inside of Visual
    Studio.
   Visual Studio also allows you to debug client script running
    inside a browser.

   This is useful if you write a lot of JavaScript and need to walk
    through the code line by line and use the other features of the
    debugging toolset.

   To get started, you need to enable script debugging support
    inside the browser.

   To do so, you open Microsoft Internet Explorer and select
    Tools | Internet Options.

   Click the Advanced tab. Find the Browsing node in the Settings
    tree and clear the Disable Script Debugging (Internet
    Explorer) check box.
   There are tools and support inside of ASP.NET that
    allow you to instrument your code with tracing and
    monitor your application.

   In addition, these features allow you to examine
    statistics and usage on your Web site.
   Tracing is the process of emitting data about a
    running application.

   In ASP.NET, this data is logged to a trace log file that
    you can access through a Web browser.

   The data provides important information about your
    site, such as who accessed the site, what the results
    were, what the various HTTP data looked like, and
    much more.

   You can also inject your own tracing calls into your
    code. This data will be emitted alongside the
    ASP.NET data
   You enable tracing through the Web.config
    file.

   You can edit this file manually or you can use
    the Web Site Administration Tool (WSAT) to
    provide a user-friendly interface to enable
    and configure tracing.
1.   Open the WSAT by selecting Website | ASP.NET
     Configuration from the Visual Studio menu.

2.   On the home page, click the Application tab of the WSAT.
     This will bring up settings for your application.

3.   On the Application tab, click Configure Debugging And
     Tracing (bottom right).

4.   Select the Capture Tracing Information check box. This
     enables the tracing features to be changed as necessary.
   You do so by editing attributes of the <trace>
    element. This element is nested under
    <configuration><system.web>.

    <configuration>
    <system.web>
    <trace enabled="true"
    requestLimit="100"
    pageOutput="false"
    traceMode="SortByTime"
    localOnly="false"
    mostRecent="true" />
    <system.web>
    </configuration>
   You can also enable tracing for specific pages only.

   This is useful if you do not wish to turn on tracing at the
    site level, but instead enable it only on a page you are
    troubleshooting.

   You enable tracing at the page level by setting the trace
    attribute of the @ Page directive to true.

   This is found at the top of the page’s markup.

   <@Page trace="true" ... />
   Once it is configured and turned on, you can
    view the ASP.NET trace data on each Web page
    (pageOutput=”true”)
    or

   View the trace output by navigating to the
    Trace.axd page on the current Web application
    (http://server/application/trace.axd).
   You can add your own trace messages to the data
    that is output by ASP.NET tracing through the Trace
    class in the System.Diagnostics namespace.

   This class is exposed as a member of the Page object.

   This allows you to call Page.Trace (or just Trace).

   Use the Write method of this object to output a
    message to the trace log.

   You can provide a category and the message.
protected void Page_Load(object sender, EventArgs e)
{
Trace.Write("Custom Category", "Page_Load called");
}
protected void Button1_Click(object sender, EventArgs e)
{
Trace.Write("Custom Category", "Button1_Click called");
}
   AJAX-enabled applications tend to have a lot of client
    code. You have to try to debug the code as it executes in
    the browser

   For this reason, the Microsoft AJAX Library provides the
    Sys.Debug client-side namespace.
   The tracing you enable on the server is not fired for
    AJAX partial-page requests. Therefore, you will see
    nothing in the Trace.axd log for these types of requests.
   Instead, you have to use the features of Sys.Debug to
    write out trace messages.

   The Debug class includes the
    assert, trace, clearTrace, traceDump, and fail methods.
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>AJAX Trace Example</title>
<script language="javascript" type="text/javascript">
function button1_onclick() {
Sys.Debug.trace("Button1 clicked");
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<input id="Button1" type="button" value="button"
onclick="button1_onclick()" />
</div>
</form>
</body>
</html>
   You can view the trace messages output by the AJAX
    library in the Visual Studio Output window.

   However, you can also create a TextArea control on the
    page that includes your JavaScript.

   You set the TextArea control’s ID to TraceConsole. This
    will tell the Microsoft AJAX library to output its trace
    messages to this TextArea for you to view.
   The features of ASP.NET health monitoring can be used
    to monitor the application and be notified of various
    events such as error conditions, security issues, and
    request failures.

   ASP.NET health monitoring provides a set of classes in
    the System.Web.Management namespace for tracking the
    health of your application.

   You can use these classes to create your own events and
    your own custom event listeners (and viewers).

   You can also use the default features exposed by these
    classes to monitor most aspects of any running Web
    application.
   The health monitoring system works by raising and
    logging ASP.NET events based on your configuration.

   You enable these events based on what you wish to
    monitor with respect to your application’s performance
    and health.

   The monitoring happens in a deployed environment.

   You can use the features of health monitoring to receive
    e-mails about important activities, to log information to
    the event log, and to log information to SQL Server.
   The first step in health monitoring is determining for
    which events you intend to listen.

   These events are defined as classes.

   For example, a given Web health monitoring event class
    might contain information about the process executing
    your code, the HTTP request, the HTTP response, and
    error conditions.
   The first step in health monitoring is determining for
    which events you intend to listen.

   These events are defined as classes.

   For example, a given Web health monitoring event class
    might contain information about the process executing
    your code, the HTTP request, the HTTP response, and
    error conditions.
   Once you know for which events you intend to listen,
    the second step is to enable a listener (or log).

   The ASP.NET health monitoring system defines a set of
    providers (or listeners) that are used to collect the Web
    event information.

   These listeners consume the Web health events and
    typically log the given event details.

   You can leverage the default listeners or write your own
    by extending the existing WebEventProvider class.

   The default providers include EventLogWebEventProvider,
    WmiWebEventProvider, and SqlWebEventProvider.
   You turn on Web events and connect them to listeners
    inside the Web.config file.

   To do so, you configure the <healthMonitoring> element
    of the Web.config file.

   The healthMonitoring element contains the enabled
    attribute, which you set to true to enable health
    monitoring.

   It also contains the attribute heartbeatInterval.

   You can set this to the number of seconds to wait
    between raising the WebHeartbeatEvent.

   The individual events themselves also contain the
    minInterval attribute that works in a similar fashion.
    The process of configuring a Web event and provider is
     as follows:

1.   Add an eventMappings child element to healthMonitoring.
     You use the add element to add the Web event class you
     wish to use.

2.   Add a providers child element to healthMonitoring. This
     indicates your health monitoring listener(s).

3.   Finally, add a rules element to healthMonitoring. You use
     the add child element of rules to indicate an association
     between a registered Web event and registered listener.
<configuration>
<system.web>
<healthMonitoring enabled="true" heartbeatInterval="1">
<rules>

<add name="Heart Beat“ eventName="Heartbeats"
provider="EventLogProvider“ profile="Default"/>

<add name="App Lifetime“ eventName="Application Lifetime
   Events“ provider="EventLogProvider“ profile="Default“
   minInstances="1“ minInterval="“ maxLimit="Infinite"/>

</rules>
</healthMonitoring>
<system.web>
<configuration>

More Related Content

What's hot

ASP.NET 02 - How ASP.NET Works
ASP.NET 02 - How ASP.NET WorksASP.NET 02 - How ASP.NET Works
ASP.NET 02 - How ASP.NET WorksRandy Connolly
 
Claims based authentication in share point 2010 .new
Claims based authentication in share point 2010 .newClaims based authentication in share point 2010 .new
Claims based authentication in share point 2010 .newRavikantChaturvedi
 
( 2 ) Office 2007 Create A Portal
( 2 ) Office 2007   Create A Portal( 2 ) Office 2007   Create A Portal
( 2 ) Office 2007 Create A PortalLiquidHub
 
RubyOnRails-Cheatsheet-BlaineKendall
RubyOnRails-Cheatsheet-BlaineKendallRubyOnRails-Cheatsheet-BlaineKendall
RubyOnRails-Cheatsheet-BlaineKendalltutorialsruby
 
Sharepoint 2010 mcq
Sharepoint 2010 mcqSharepoint 2010 mcq
Sharepoint 2010 mcqAnuja Sharma
 
( 13 ) Office 2007 Coding With Excel And Excel Services
( 13 ) Office 2007   Coding With Excel And Excel Services( 13 ) Office 2007   Coding With Excel And Excel Services
( 13 ) Office 2007 Coding With Excel And Excel ServicesLiquidHub
 
Web II - 02 - How ASP.NET Works
Web II - 02 - How ASP.NET WorksWeb II - 02 - How ASP.NET Works
Web II - 02 - How ASP.NET WorksRandy Connolly
 
Java Server Faces (JSF) - advanced
Java Server Faces (JSF) - advancedJava Server Faces (JSF) - advanced
Java Server Faces (JSF) - advancedBG Java EE Course
 
Oa Framework Tutorial
Oa Framework TutorialOa Framework Tutorial
Oa Framework Tutorialnolimit797
 
Making Sense of APEX Security by Christoph Ruepprich
Making Sense of APEX Security by Christoph RuepprichMaking Sense of APEX Security by Christoph Ruepprich
Making Sense of APEX Security by Christoph RuepprichEnkitec
 
9 Most Common HTTP Errors Explained
 9 Most Common HTTP Errors Explained 9 Most Common HTTP Errors Explained
9 Most Common HTTP Errors ExplainedAmit Kute
 
JSF 2.0 (JavaEE Webinar)
JSF 2.0 (JavaEE Webinar)JSF 2.0 (JavaEE Webinar)
JSF 2.0 (JavaEE Webinar)Roger Kitain
 
Servlet and jsp interview questions
Servlet and jsp interview questionsServlet and jsp interview questions
Servlet and jsp interview questionsSujata Regoti
 
Introductionto asp net-ppt
Introductionto asp net-pptIntroductionto asp net-ppt
Introductionto asp net-ppttmasyam
 
License4J Auto License Generation and Activation Server
License4J Auto License Generation and Activation ServerLicense4J Auto License Generation and Activation Server
License4J Auto License Generation and Activation ServerMehmet Yilmaz
 

What's hot (17)

ASP.NET 02 - How ASP.NET Works
ASP.NET 02 - How ASP.NET WorksASP.NET 02 - How ASP.NET Works
ASP.NET 02 - How ASP.NET Works
 
Claims based authentication in share point 2010 .new
Claims based authentication in share point 2010 .newClaims based authentication in share point 2010 .new
Claims based authentication in share point 2010 .new
 
( 2 ) Office 2007 Create A Portal
( 2 ) Office 2007   Create A Portal( 2 ) Office 2007   Create A Portal
( 2 ) Office 2007 Create A Portal
 
Struts Intro
Struts IntroStruts Intro
Struts Intro
 
RubyOnRails-Cheatsheet-BlaineKendall
RubyOnRails-Cheatsheet-BlaineKendallRubyOnRails-Cheatsheet-BlaineKendall
RubyOnRails-Cheatsheet-BlaineKendall
 
Sharepoint 2010 mcq
Sharepoint 2010 mcqSharepoint 2010 mcq
Sharepoint 2010 mcq
 
( 13 ) Office 2007 Coding With Excel And Excel Services
( 13 ) Office 2007   Coding With Excel And Excel Services( 13 ) Office 2007   Coding With Excel And Excel Services
( 13 ) Office 2007 Coding With Excel And Excel Services
 
Web II - 02 - How ASP.NET Works
Web II - 02 - How ASP.NET WorksWeb II - 02 - How ASP.NET Works
Web II - 02 - How ASP.NET Works
 
Java Server Faces (JSF) - advanced
Java Server Faces (JSF) - advancedJava Server Faces (JSF) - advanced
Java Server Faces (JSF) - advanced
 
Oa Framework Tutorial
Oa Framework TutorialOa Framework Tutorial
Oa Framework Tutorial
 
Jsp element
Jsp elementJsp element
Jsp element
 
Making Sense of APEX Security by Christoph Ruepprich
Making Sense of APEX Security by Christoph RuepprichMaking Sense of APEX Security by Christoph Ruepprich
Making Sense of APEX Security by Christoph Ruepprich
 
9 Most Common HTTP Errors Explained
 9 Most Common HTTP Errors Explained 9 Most Common HTTP Errors Explained
9 Most Common HTTP Errors Explained
 
JSF 2.0 (JavaEE Webinar)
JSF 2.0 (JavaEE Webinar)JSF 2.0 (JavaEE Webinar)
JSF 2.0 (JavaEE Webinar)
 
Servlet and jsp interview questions
Servlet and jsp interview questionsServlet and jsp interview questions
Servlet and jsp interview questions
 
Introductionto asp net-ppt
Introductionto asp net-pptIntroductionto asp net-ppt
Introductionto asp net-ppt
 
License4J Auto License Generation and Activation Server
License4J Auto License Generation and Activation ServerLicense4J Auto License Generation and Activation Server
License4J Auto License Generation and Activation Server
 

Viewers also liked

Devel::hdb debugger talk
Devel::hdb debugger talkDevel::hdb debugger talk
Devel::hdb debugger talkabrummett
 
Cloudwatch - The In's and Out's
Cloudwatch - The In's and Out'sCloudwatch - The In's and Out's
Cloudwatch - The In's and Out'sbeaknit
 
S4 trouble shooting, AgencY S4
S4 trouble shooting, AgencY S4S4 trouble shooting, AgencY S4
S4 trouble shooting, AgencY S4S4 (sale4.me)
 
Site24x7 Cloud Monitoring
Site24x7 Cloud MonitoringSite24x7 Cloud Monitoring
Site24x7 Cloud MonitoringSite24x7
 
Java performance and trouble shooting
Java performance and trouble shootingJava performance and trouble shooting
Java performance and trouble shootingAnna Choi
 
Redis trouble shooting_eng
Redis trouble shooting_engRedis trouble shooting_eng
Redis trouble shooting_engDaeMyung Kang
 
Using dynaTrace to optimise application performance
Using dynaTrace to optimise application performanceUsing dynaTrace to optimise application performance
Using dynaTrace to optimise application performanceRichard Bishop
 

Viewers also liked (8)

Devel::hdb debugger talk
Devel::hdb debugger talkDevel::hdb debugger talk
Devel::hdb debugger talk
 
Cloudwatch - The In's and Out's
Cloudwatch - The In's and Out'sCloudwatch - The In's and Out's
Cloudwatch - The In's and Out's
 
S4 trouble shooting, AgencY S4
S4 trouble shooting, AgencY S4S4 trouble shooting, AgencY S4
S4 trouble shooting, AgencY S4
 
Site24x7 Cloud Monitoring
Site24x7 Cloud MonitoringSite24x7 Cloud Monitoring
Site24x7 Cloud Monitoring
 
Java performance and trouble shooting
Java performance and trouble shootingJava performance and trouble shooting
Java performance and trouble shooting
 
Redis trouble shooting_eng
Redis trouble shooting_engRedis trouble shooting_eng
Redis trouble shooting_eng
 
Using dynaTrace to optimise application performance
Using dynaTrace to optimise application performanceUsing dynaTrace to optimise application performance
Using dynaTrace to optimise application performance
 
Metrics 101
Metrics 101Metrics 101
Metrics 101
 

Similar to Debug ASP.NET Apps with Tracing and Debugging Tools

Share point 2010_overview-day4-code
Share point 2010_overview-day4-codeShare point 2010_overview-day4-code
Share point 2010_overview-day4-codeNarayana Reddy
 
Share point 2010_overview-day4-code
Share point 2010_overview-day4-codeShare point 2010_overview-day4-code
Share point 2010_overview-day4-codeNarayana Reddy
 
11 asp.net session16
11 asp.net session1611 asp.net session16
11 asp.net session16Vivek chan
 
13 asp.net session19
13 asp.net session1913 asp.net session19
13 asp.net session19Vivek chan
 
High performance coding practices code project
High performance coding practices code projectHigh performance coding practices code project
High performance coding practices code projectPruthvi B Patil
 
New Features Of ASP.Net 4 0
New Features Of ASP.Net 4 0New Features Of ASP.Net 4 0
New Features Of ASP.Net 4 0Dima Maleev
 
SCWCD : Handling exceptions : CHAP : 5
SCWCD : Handling exceptions : CHAP : 5SCWCD : Handling exceptions : CHAP : 5
SCWCD : Handling exceptions : CHAP : 5Ben Abdallah Helmi
 
Useful Rails Plugins
Useful Rails PluginsUseful Rails Plugins
Useful Rails Pluginsnavjeet
 
16 asp.net session23
16 asp.net session2316 asp.net session23
16 asp.net session23Vivek chan
 
Load Testing with WAPT: Quick Start Guide
Load Testing with WAPT: Quick Start GuideLoad Testing with WAPT: Quick Start Guide
Load Testing with WAPT: Quick Start GuideSoftLogica
 
ASP.NET 05 - Exception Handling And Validation Controls
ASP.NET 05 - Exception Handling And Validation ControlsASP.NET 05 - Exception Handling And Validation Controls
ASP.NET 05 - Exception Handling And Validation ControlsRandy Connolly
 
Classic asp , VB.net insert update delete crud
Classic asp , VB.net insert update delete crudClassic asp , VB.net insert update delete crud
Classic asp , VB.net insert update delete crudParakram Chavda
 
Programming web application
Programming web applicationProgramming web application
Programming web applicationaspnet123
 
Rc085 010d-vaadin7
Rc085 010d-vaadin7Rc085 010d-vaadin7
Rc085 010d-vaadin7Cosmina Ivan
 

Similar to Debug ASP.NET Apps with Tracing and Debugging Tools (20)

Share point 2010_overview-day4-code
Share point 2010_overview-day4-codeShare point 2010_overview-day4-code
Share point 2010_overview-day4-code
 
Share point 2010_overview-day4-code
Share point 2010_overview-day4-codeShare point 2010_overview-day4-code
Share point 2010_overview-day4-code
 
11 asp.net session16
11 asp.net session1611 asp.net session16
11 asp.net session16
 
NET_Training.pptx
NET_Training.pptxNET_Training.pptx
NET_Training.pptx
 
13 asp.net session19
13 asp.net session1913 asp.net session19
13 asp.net session19
 
High performance coding practices code project
High performance coding practices code projectHigh performance coding practices code project
High performance coding practices code project
 
New Features Of ASP.Net 4 0
New Features Of ASP.Net 4 0New Features Of ASP.Net 4 0
New Features Of ASP.Net 4 0
 
SCWCD : Handling exceptions : CHAP : 5
SCWCD : Handling exceptions : CHAP : 5SCWCD : Handling exceptions : CHAP : 5
SCWCD : Handling exceptions : CHAP : 5
 
Exception handling
Exception handlingException handling
Exception handling
 
Useful Rails Plugins
Useful Rails PluginsUseful Rails Plugins
Useful Rails Plugins
 
70562 (1)
70562 (1)70562 (1)
70562 (1)
 
16 asp.net session23
16 asp.net session2316 asp.net session23
16 asp.net session23
 
Load Testing with WAPT: Quick Start Guide
Load Testing with WAPT: Quick Start GuideLoad Testing with WAPT: Quick Start Guide
Load Testing with WAPT: Quick Start Guide
 
Qa process
Qa processQa process
Qa process
 
ASP.NET 05 - Exception Handling And Validation Controls
ASP.NET 05 - Exception Handling And Validation ControlsASP.NET 05 - Exception Handling And Validation Controls
ASP.NET 05 - Exception Handling And Validation Controls
 
Classic asp , VB.net insert update delete crud
Classic asp , VB.net insert update delete crudClassic asp , VB.net insert update delete crud
Classic asp , VB.net insert update delete crud
 
Qa process
Qa processQa process
Qa process
 
Programming web application
Programming web applicationProgramming web application
Programming web application
 
Rc085 010d-vaadin7
Rc085 010d-vaadin7Rc085 010d-vaadin7
Rc085 010d-vaadin7
 
DEVICE CHANNELS
DEVICE CHANNELSDEVICE CHANNELS
DEVICE CHANNELS
 

More from aspnet123

Deploying configuring caching
Deploying configuring cachingDeploying configuring caching
Deploying configuring cachingaspnet123
 
Mobile application
Mobile applicationMobile application
Mobile applicationaspnet123
 
Globalization and accessibility
Globalization and accessibilityGlobalization and accessibility
Globalization and accessibilityaspnet123
 
User controls
User controlsUser controls
User controlsaspnet123
 
Custom controls
Custom controlsCustom controls
Custom controlsaspnet123
 
Web services
Web servicesWeb services
Web servicesaspnet123
 
Working with xml data
Working with xml dataWorking with xml data
Working with xml dataaspnet123
 
Connected data classes
Connected data classesConnected data classes
Connected data classesaspnet123
 
Disconnected data
Disconnected dataDisconnected data
Disconnected dataaspnet123
 
Introducing asp
Introducing aspIntroducing asp
Introducing aspaspnet123
 

More from aspnet123 (11)

Deploying configuring caching
Deploying configuring cachingDeploying configuring caching
Deploying configuring caching
 
Mobile application
Mobile applicationMobile application
Mobile application
 
Profile
ProfileProfile
Profile
 
Globalization and accessibility
Globalization and accessibilityGlobalization and accessibility
Globalization and accessibility
 
User controls
User controlsUser controls
User controls
 
Custom controls
Custom controlsCustom controls
Custom controls
 
Web services
Web servicesWeb services
Web services
 
Working with xml data
Working with xml dataWorking with xml data
Working with xml data
 
Connected data classes
Connected data classesConnected data classes
Connected data classes
 
Disconnected data
Disconnected dataDisconnected data
Disconnected data
 
Introducing asp
Introducing aspIntroducing asp
Introducing asp
 

Recently uploaded

Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?XfilesPro
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAndikSusilo4
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 

Recently uploaded (20)

Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & Application
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 

Debug ASP.NET Apps with Tracing and Debugging Tools

  • 1.
  • 2. Setting up debugging  Creating custom errors  Debugging on a remote server  Debugging client script  Troubleshooting  Monitoring a running ASP.NET site
  • 3. You can debug an ASP.NET application using the standard features of the Visual Studio debugger like setting breakpoints in code, to view variable values in watch windows, to step-through code inside the Integrated Development Environment (IDE), to extract error information, to execute code in the command window and the like.  To do so, you must first configure ASP.NET for debugging.  There are two areas where you can configure: 1. the project’s property page and 2. the Web.config file.
  • 4. The first step is to enable the ASP.NET debugger in your project’s Property Pages dialog box. 1. Right-click the Web site in Solution Explorer to open the shortcut menu. 2. Select Property Pages from the shortcut menu. This will open the Property Pages dialog box for the given Web site 3. Select Start Options from the left side of the dialog box. 4. In the Debuggers section, at the bottom of the dialog box, select (or clear) the ASP.NET check box to enable (or disable) the ASP.NET debugger for Visual Studio.
  • 5. The second step is to enable debugging either for your entire site or on a page-by-page basis.  You enable debugging for your entire site through the Web.config file by setting the debug attribute of the compilation element to true. <configuration> <system.web> <compilation debug="true"> </compilation> <system.web> </configuration>  To enable page-level debugging, set the Debug attribute of the @ Page directive <%@ Page Debug="true" ... %>
  • 6. You do not want to show users the default, ASP.NET error page if your site happens to break.  You most likely want users to see a page that instructs them on how they can contact support to resolve the problem.  You can configure your site to display a generic error page if users happen to encounter an unhandled error. 1. Can set this page at the site level. 2. Can also set individual pages for specific error types
  • 7. You configure custom errors inside the Web.config file using the <customErrors> element nested inside <system.web>.  This element has the attributes mode and defaultRedirect.  The mode attribute can be set to on to turn custom errors on, off to turn them off, or RemoteOnlyto turn custom errors on for remote clients only.  The defaultRedirect attribute is used to indicate the path to a default error page.
  • 8. <configuration> <system.web> <customErrors defaultRedirect="SiteErrorPage.aspx" mode="RemoteOnly"> </customErrors> <system.web> </configuration>  On redirection, the server passes the path of the page that caused the error. This path is provided as part of the query string using the named parameter aspxErrorPath. http://localhost/examples/SiteErrorPage.aspx?aspxerrorpath=/examples/Default.aspx
  • 9. It is also possible to define specific pages for various HTTP status codes.  This allows you to provide more specific information to users when they hit a given status code.  For example, if users do not have access to a given page or resource, they will be shown the HTTP error 403.  This status code indicates they are denied access to the resource.  You can then write a custom page that explains the process for obtaining access to a given resource.  Use the <error> element to redirect to that custom page.
  • 10. <configuration> <system.web> <customErrors defaultRedirect="SiteErrorPage.aspx" mode="RemoteOnly"> <error statusCode="403" redirect="RestrictedAccess.aspx" /> </customErrors> <system.web> </configuration>
  • 11. The process of enabling remote debugging is made easier through the Remote Debugging Monitor (Msvsmon.exe).  You run this tool on the server you intend to debug.  The tool can be found inside your development environment installation folder (for example, Program FilesMicrosoft Visual Studio 9.0Common7IDE Remote Debuggerx64).  You can copy the .exe to a file share or over to the server.  You can also install the tool from the Visual Studio DVD set.
  • 12. You begin a remote debugging session by opening Visual Studio and a solution that includes the code you intend to debug.  You can then attach to the server running the Remote Debugging Monitor application from the Debug menu by selecting Attach To Process.  This opens the Attach To Process dialog box.  In this dialog box, you set the Qualifier to the name of the server running the Remote Debugging Monitor.
  • 13. The server name is set in the Options dialog box for the Remote Debugging Monitor and typically is defined as User@Server.  You will then see a list of running processes on the server.  Select the ASP.NET Web server process and click Attach to start remote debugging.  Hit the server through a browser to cause a breakpoint to fire or an error to occur.  Doing so will send you into debug mode inside of Visual Studio.
  • 14. Visual Studio also allows you to debug client script running inside a browser.  This is useful if you write a lot of JavaScript and need to walk through the code line by line and use the other features of the debugging toolset.  To get started, you need to enable script debugging support inside the browser.  To do so, you open Microsoft Internet Explorer and select Tools | Internet Options.  Click the Advanced tab. Find the Browsing node in the Settings tree and clear the Disable Script Debugging (Internet Explorer) check box.
  • 15. There are tools and support inside of ASP.NET that allow you to instrument your code with tracing and monitor your application.  In addition, these features allow you to examine statistics and usage on your Web site.
  • 16. Tracing is the process of emitting data about a running application.  In ASP.NET, this data is logged to a trace log file that you can access through a Web browser.  The data provides important information about your site, such as who accessed the site, what the results were, what the various HTTP data looked like, and much more.  You can also inject your own tracing calls into your code. This data will be emitted alongside the ASP.NET data
  • 17.
  • 18. You enable tracing through the Web.config file.  You can edit this file manually or you can use the Web Site Administration Tool (WSAT) to provide a user-friendly interface to enable and configure tracing.
  • 19. 1. Open the WSAT by selecting Website | ASP.NET Configuration from the Visual Studio menu. 2. On the home page, click the Application tab of the WSAT. This will bring up settings for your application. 3. On the Application tab, click Configure Debugging And Tracing (bottom right). 4. Select the Capture Tracing Information check box. This enables the tracing features to be changed as necessary.
  • 20. You do so by editing attributes of the <trace> element. This element is nested under <configuration><system.web>. <configuration> <system.web> <trace enabled="true" requestLimit="100" pageOutput="false" traceMode="SortByTime" localOnly="false" mostRecent="true" /> <system.web> </configuration>
  • 21. You can also enable tracing for specific pages only.  This is useful if you do not wish to turn on tracing at the site level, but instead enable it only on a page you are troubleshooting.  You enable tracing at the page level by setting the trace attribute of the @ Page directive to true.  This is found at the top of the page’s markup.  <@Page trace="true" ... />
  • 22. Once it is configured and turned on, you can view the ASP.NET trace data on each Web page (pageOutput=”true”) or  View the trace output by navigating to the Trace.axd page on the current Web application (http://server/application/trace.axd).
  • 23.
  • 24. You can add your own trace messages to the data that is output by ASP.NET tracing through the Trace class in the System.Diagnostics namespace.  This class is exposed as a member of the Page object.  This allows you to call Page.Trace (or just Trace).  Use the Write method of this object to output a message to the trace log.  You can provide a category and the message.
  • 25. protected void Page_Load(object sender, EventArgs e) { Trace.Write("Custom Category", "Page_Load called"); } protected void Button1_Click(object sender, EventArgs e) { Trace.Write("Custom Category", "Button1_Click called"); }
  • 26. AJAX-enabled applications tend to have a lot of client code. You have to try to debug the code as it executes in the browser  For this reason, the Microsoft AJAX Library provides the Sys.Debug client-side namespace.  The tracing you enable on the server is not fired for AJAX partial-page requests. Therefore, you will see nothing in the Trace.axd log for these types of requests.  Instead, you have to use the features of Sys.Debug to write out trace messages.  The Debug class includes the assert, trace, clearTrace, traceDump, and fail methods.
  • 27. <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <title>AJAX Trace Example</title> <script language="javascript" type="text/javascript"> function button1_onclick() { Sys.Debug.trace("Button1 clicked"); } </script> </head> <body> <form id="form1" runat="server"> <div> <asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager> <input id="Button1" type="button" value="button" onclick="button1_onclick()" /> </div> </form> </body> </html>
  • 28. You can view the trace messages output by the AJAX library in the Visual Studio Output window.  However, you can also create a TextArea control on the page that includes your JavaScript.  You set the TextArea control’s ID to TraceConsole. This will tell the Microsoft AJAX library to output its trace messages to this TextArea for you to view.
  • 29. The features of ASP.NET health monitoring can be used to monitor the application and be notified of various events such as error conditions, security issues, and request failures.  ASP.NET health monitoring provides a set of classes in the System.Web.Management namespace for tracking the health of your application.  You can use these classes to create your own events and your own custom event listeners (and viewers).  You can also use the default features exposed by these classes to monitor most aspects of any running Web application.
  • 30. The health monitoring system works by raising and logging ASP.NET events based on your configuration.  You enable these events based on what you wish to monitor with respect to your application’s performance and health.  The monitoring happens in a deployed environment.  You can use the features of health monitoring to receive e-mails about important activities, to log information to the event log, and to log information to SQL Server.
  • 31. The first step in health monitoring is determining for which events you intend to listen.  These events are defined as classes.  For example, a given Web health monitoring event class might contain information about the process executing your code, the HTTP request, the HTTP response, and error conditions.
  • 32. The first step in health monitoring is determining for which events you intend to listen.  These events are defined as classes.  For example, a given Web health monitoring event class might contain information about the process executing your code, the HTTP request, the HTTP response, and error conditions.
  • 33.
  • 34. Once you know for which events you intend to listen, the second step is to enable a listener (or log).  The ASP.NET health monitoring system defines a set of providers (or listeners) that are used to collect the Web event information.  These listeners consume the Web health events and typically log the given event details.  You can leverage the default listeners or write your own by extending the existing WebEventProvider class.  The default providers include EventLogWebEventProvider, WmiWebEventProvider, and SqlWebEventProvider.
  • 35. You turn on Web events and connect them to listeners inside the Web.config file.  To do so, you configure the <healthMonitoring> element of the Web.config file.  The healthMonitoring element contains the enabled attribute, which you set to true to enable health monitoring.  It also contains the attribute heartbeatInterval.  You can set this to the number of seconds to wait between raising the WebHeartbeatEvent.  The individual events themselves also contain the minInterval attribute that works in a similar fashion.
  • 36. The process of configuring a Web event and provider is as follows: 1. Add an eventMappings child element to healthMonitoring. You use the add element to add the Web event class you wish to use. 2. Add a providers child element to healthMonitoring. This indicates your health monitoring listener(s). 3. Finally, add a rules element to healthMonitoring. You use the add child element of rules to indicate an association between a registered Web event and registered listener.
  • 37. <configuration> <system.web> <healthMonitoring enabled="true" heartbeatInterval="1"> <rules> <add name="Heart Beat“ eventName="Heartbeats" provider="EventLogProvider“ profile="Default"/> <add name="App Lifetime“ eventName="Application Lifetime Events“ provider="EventLogProvider“ profile="Default“ minInstances="1“ minInterval="“ maxLimit="Infinite"/> </rules> </healthMonitoring> <system.web> <configuration>