Mon. Jun 27th, 2022

In Aria-label=”Article This Article

Exceptions in web applications can be reported to Application Insights. You can associate failed requests with exceptions and other points in time, both on the client and on the web, to quickly evaluate the causes. In this article, you’ll learn how to set up exception reporting, explicitly report exceptions, diagnose crashes, and more.

Configure Exception Reporting

You mentioned that new exceptions can be added to Application Insights, which usually occur on the server or client. Depending on the platform your application is primarily running on, you will need an appropriate proxy or SDK.


For the server application to report exceptions, select the following scenarios:

  • Azure Web Apps: Add Application Insights extension
  • V Azure VM and Azure Virtual Machine Scale Set. Hosted IIS Applications: Add Application Monitoring Extension.
  • Install Application Insights SDK in your instance code or
  • IIS Web Server: Run Application Insights Agent or
  • Java Web Applications: Enable Java Agent
  • Client Side

    The JavaScript SDK allows you to generate malicious client-side reporting of exceptions thrown in web browsers. To configure an exception when sending customer reports, see Application Insights for Web.


    Some People Frameworks applications require additional configuration, consider the following technologies:

  • Web Forms
  • MVC
  • Web API 1.*
  • Web API 2.*
  • WCF
  • Diagnosing Exceptions With Visual Studio

    Where can I find the insight user manual?

    This User Guide is provided as a PDF file on the product CD and on the Inner Range website. See the tip on page 10. The Insight software has a comprehensive online help.

    Open the mobile app solution in Visual Studio. Run someone’s application either on your server or on your development machine using F5. Rethrow the exception.

    Open the Application Insights search telemetry window in Visual Studio. While debugging, select the Application Insights drop-down menu.

    Select the exception report if you want to view its stack trace. To open the corresponding code file, select the line link in the add trace.

    Diagnose Errors Using The Azure Portal

    Application Insights includes an Application Performance Management (APM) feature designed to help diagnose errors in monitored computer software. First, in the Bugs section, select your own option from the Application Insights Blog menu under Exploration.
    You’ll see the types of error rates for your requests, how they fail, and a lot of information about the impact on users. In the overview, you can see some of the most useful distributions specific to the selected failed operation, including the main different response codes, the three most common examples of exceptions, and the three types of dependencies that most often fail.

    Choose the appropriate link to get representative validation samples for each of these subsets.Operations. Typically, as an example of diagnosing exceptions, you can choose the number of a specific exception, which is displayed on the tab “Cross-cutting details”:

    Alternatively, instead of viewing exceptions for a specific failed process, you can start by viewing global exceptions, preferably by turning off the Exceptions tab. Here you can see all exceptions thrown for your monitored application.

    Custom Tracking And Registration Data

    To get historical diagnostics for your application, anyone can inject code to send their own telemetry. Your business telemetry or log data is in a visible diagnostic search along with the request, form submission, and other automatically retrieved data.

  • TelemetryClient.TrackEvent is typically used to track eating habits, but submitted data also appears in the Custom Events section with diagnostic search. Events are referenced and can contain string properties and numeric Metrics that can also be used to filter diagnostic searches.
  • You can use TelemetryClient.TrackTrace to return longer data such as POST information.
  • TelemetryClient.TrackException sends exception details such as load traces to Application Insights.
  • To view these events, use Search to open the remaining menu, select the “Event Types” drop-down menu, then select “Custom Event”, “Track”, or “Exception”.

    How To Get POST Data

    Request not enabled. You see the data sent to your application during the POST call. Reported excellent data on this occasion:

  • Install the SDK in the application project.
  • Add code to your registry to call Microsoft.ApplicationInsights.TrackTrace(). Send the POST data in a message parameter. There is one to limit the given size, so you should try to make sure you send only the required data.
  • If you examine the failed request, you can find specific traces associated with it.
  • Capturing Exceptions And Related Diagnostic Data

    Won’t you first see all the downgrades that cause errors in your software package in the portal? You will see all browser terms (if you use the JavaScript SDK on all your web pages). But most web exceptions are caught by IIS and you need to write a small piece of code to see them.

  • Log omissions explicitly thrown by code into exceptions for these rule engines to report exceptions.
  • Catch exceptions automatically by setting up ASP.NET composition. Required add-ons vary by platform type.
  • Easiest Way To Explicitly Report Exceptions

    The way is to put a big trackException() call in the diff handler.


    // ... catch (example) appInsights.trackException(e.g. Loc", "Merchants game: name of the current game, State: currentGame.State.ToString() );
    var telemetry = brand new TelemetryClient();
    To attempt
        // ...
    capture (exclusion for example)
        var is immovable t=new line>
            ["user"] = currentgame.user.count
        // send exception telemetry:
        telemetry.TrackException (e.g. properties, telemetry metrics);
    Dim equals New TelemetryClient
    To attempt
    Catch your ex as an exception
        'Set up some properties:
        DimProperties means new dictionary (from string, string)
       Properties .Add("game",
        Dim Measures = New dictionary (double)
     string, measurements.Add("user", currentgame.user.count)
        do not send telemetry:
     Exception telemetry. TrackException (e.g. properties, metrics)
    Try Final Properties

    Parameters and metrics are optional, but still useful for filtering and adding additional information. For example, if someone has an application that can run multiple games, you can find almost every exception report related to a particular important game. You can add as many items as you want to each dictionary.

    Browser Exceptions

    If your web view includesFor scripts from file sharing networks or other domains, ensure that this script tag includes the crossorigin="anonymous" clause and that the server removes the CORS-Header< /code>. a>. This allows you to get stack traces and characteristics of unhandled JavaScript exceptions from some of these resources.

    Reuse Telemetry Client

    With Dependency Injection (DI) in .NET that conforms to the .NET SDK and properly configured Application Insights for DI, you can request the entire TelemetryClient as a parameter constructor.

    Open Lesson ExampleController: ApiController
        hidden _telemetryClient read-only;
     telemetryclient public ExampleController(TelemetryClient telemetryClient)
            _telemetryClient is telemetryClient;

    The last example puts the TelemetryClient directly into the ExampleController class.

    Web Forms

    For the web, the HTTP engine can catch exceptions when there are no redirects configured at all that offer