Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Web.Mvc;
- using Microsoft.ApplicationInsights;
- namespace WebApplication10.ErrorHandler //namespace will vary based on your project name
- {
- [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, Inherited = true, AllowMultiple = true)]
- public class AiHandleErrorAttribute : HandleErrorAttribute
- {
- public override void OnException(ExceptionContext filterContext)
- {
- if (filterContext != null && filterContext.HttpContext != null && filterContext.Exception != null)
- {
- //If customError is Off, then AI HTTPModule will report the exception
- if (filterContext.HttpContext.IsCustomErrorEnabled)
- {
- var ai = new TelemetryClient();
- ai.TrackException(filterContext.Exception);
- }
- }
- base.OnException(filterContext);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement