My Development Notes

By Haemoglobin
3/10/2010 (revision 1)

Monitoring, Troubleshooting, Debugging

Custom Errors

configuration
    system.web
        customErrors defaultRedirect="ErrorPage.aspx" mode="RemoteOnly"
//On redirect aspxerrorpath=/path/offendingpage.aspx is passed as a parameter   

Remote Debugging

Debugging a server remotely can be achieve by installing the Remote Debugging Monitor on the server and configuring developer rights, and then attaching to the ASP.NET worker process from the development machine.

Debugging Client Side Script

IE: Tools &rarr Internet Options &rarr Settings and clear "Disable Script Debugging"

Tracing

ASP.NET Tracing collects the following by default

  • Request details
  • Trace information
  • Controls - the controls on the page, their view state.
  • Session / Application State
  • Request / response Cookies
  • Headers
  • Form data
  • Query string values
  • Server variables

Can be set through the Web Site Administration Tool or through the web.config:

configuration
    system.web
        trace enabled="true" 
        requestLimit="100" //the number of items to store in the cache
        pageOutput="false" //displays trace output at the bottom of the page
        traceMode="SortByTime" //either by time or category
        localOnly="false" //if true tracing is only done on local requests
        mostRecent="true" //if false tracing stops once cache fills up. 

Tracing can be turned on at the page level by adding:


<@Page trace="true"> 

If tracing isn't enabled on the page level all requests in the cache can be viewed by browsing to the virtual trace.axd.

Custom tracing can be output using:

Trace.Write("Custom Category", traceText);

Debugging AJAX

Server side tracing does not log AJAX requests back to the server.

Sys.Debug.trace("button clicked");

These will appear in the visual studio output tab (if IE is being used with debugging enabled).
Or you can add a textarea to the page and set it's ID to "TraceConsole" and ASP.NET will redirect output to the textarea.

Monitoring a Running Web Application

configuration
    system.web
        healthMonitoring enabled="true" heartbeatInterval="1"
            /*
            machine.config defines eventMappings 
                WebBaseEvent 
                WebManagementEvent 
                WebHeartbeatEvent 
                WebRequestEvent 
                WebApplicationLifetimeEvent 
                WebBaseErrorEvent 
                WebErrorEvent 
                WebRequestErrorEvent 
                WebAuditEvent 
                WebSuccessAuditEvent 
                WebAuthenticationSuccessAuditEvent 
                WebFailureAuditEvent 
                WebAuthenticationFailureAuditEvent 
                WebViewStateFailureAuditEvent

            machine.config defines providers. Only the EventLogWebEventProvider, SqlWebEventProvider, and WmiWebEventProvider  event providers are preconfigured in the root Web.config file. */
            rules
                add name="Heart Beat"
                    eventName="Heartbeats" //as defined in eventMappings
                    provider="EventLogProvider" //as defined in providers
                    profile="Default" //Default and Critical are the two default profiles setup in ASP.NET

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

Comments

Powered by BlogEngine.NET 1.6.1.0 | Design by styleshout | Enhanced by GravityCube.net | 1.4.5 Changes by zembian.com | Adapted by HamishGraham.NET
(c) 2010 Hamish Graham. Banner Image (c) Chris Gin