Chat Support
Loupe - Log - Monitor - Resolve
Loupe / Getting Started / .NET Framework / Using Loupe with ASP.NET MVC - Introduction
In This Topic
    Using Loupe with ASP.NET MVC - Introduction
    In This Topic

    Because ASP.NET is essentially a set of libraries that runs on top of the .NET runtime, all of the capabilities that make the Loupe Agent work for other .NET applications apply with web applications as well.  You can log directly into Loupe, use it with Trace or Debug, or connect it up to your favorite log system.  Some parts of the Agent don't apply to service environments like ASP.NET and are automatically disabled to ensure they won't interfere including the Live Viewer, Packager Dialog, and Error Manager Alert Dialog.  The entire API of the Agent is designed to be safe and will not attempt to display any user interface when running in ASP.NET.

    This section applies to ASP.NET MVC applications.  If you are developing for ASP.NET WebForms see Using Loupe with ASP.NET WebForms - Introduction
     Adding the Loupe Agent for ASP.NET MVC to your Web Site

    Use NuGet to add the Loupe Agent for ASP.NET MVC to your web application project.  It will automatically add the Loupe Agent to the same project.  You will often want to add the Loupe Agent to other projects in your solution, but the MVC agent only needs to be referenced in one place.

    Once the Agent has been referenced you will need to add a few lines to your application startup to insert the MVC Agent into the global filters configuration.

    using Gibraltar.Agent;
    using Gibraltar.Agent.Web.Mvc.Filters;
    public class MvcApplication : System.Web.HttpApplication
        protected void Application_Start()
            Log.StartSession(); //Prompt the Loupe Agent to start immediately
            //Register the three filters (Order is not important)
                new WebApiRequestMonitorAttribute());
            GlobalFilters.Filters.Add(new MvcRequestMonitorAttribute());
            GlobalFilters.Filters.Add(new UnhandledExceptionAttribute());
    Imports Gibraltar.Agent
    Imports Gibraltar.Agent.Web.Mvc.Filters
    Public Class MvcApplication
         Inherits System.Web.HttpApplication
         Protected Sub Application_Start()
             Log.StartSession() 'Prompt the Loupe Agent to start immediately
             'Register the three filters
             GlobalConfiguration.Configuration.Filters.Add( _
                    New WebApiRequestMonitorAttribute())
             GlobalFilters.Filters.Add(New MvcRequestMonitorAttribute())
             GlobalFilters.Filters.Add(New UnhandledExceptionAttribute())
         End Sub
    End Class

     Metrics Captured by the Loupe Agent
    For complete information on the metrics captured by the Loupe Agent for ASP.NET including what data they capture and how to view them see Using Loupe with ASP.NET - Page Hit Metric .
     Optimizing your Loupe Experience for ASP.NET MVC
    Because ASP.NET is an environment that sits on top of .NET, there are some things to understand to get the most out of Loupe.  See Using Loupe with ASP.NET - Optimizing your Experience  for more information.
    Because the Loupe Agent for ASP.NET MVC is written on top of the Loupe Agent, everything it does can be done by your own code as well.  You can extend its metrics to fit your situation more precisely.  It is intended to provide a quick start to get you going with using Loupe and ASP.NET MVC.
    See Also