Inheritance: System.EventArgs
        void ErrorLog_Logged(object sender, ErrorLoggedEventArgs args)
        {
            if (args.Entry.Error.Exception is HandledElmahException)
                return;

            var config = WebConfigurationManager.OpenWebConfiguration("~");
            var customErrorsSection = (CustomErrorsSection)config.GetSection("system.web/customErrors");

            if (customErrorsSection != null)
            {
                switch (customErrorsSection.Mode)
                {
                    case CustomErrorsMode.Off:
                        break;
                    case CustomErrorsMode.On:
                        FriendlyErrorTransfer(args.Entry.Id, customErrorsSection.DefaultRedirect);
                        break;
                    case CustomErrorsMode.RemoteOnly:
                        if (!HttpContext.Current.Request.IsLocal)
                            FriendlyErrorTransfer(args.Entry.Id, customErrorsSection.DefaultRedirect);
                        break;
                    default:
                        break;
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Raises the <see cref="Logged"/> event.
        /// </summary>

        protected virtual void OnLogged(ErrorLoggedEventArgs args)
        {
            ErrorLoggedEventHandler handler = Logged;

            if (handler != null)
            {
                handler(this, args);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Process errors caught in Global.asax
        /// <para>should be inside protected void ErrorLog_Logged(object sender, ErrorLoggedEventArgs args)</para>
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        /// <returns>null if no custom error should be displayed or a link if redirect is required to the specific location</returns>
        public static string ProcessError(object sender, ErrorLoggedEventArgs args)
        {
            if (customErrorsSection != null)
            {
                switch (customErrorsSection.Mode)
                {
                    case CustomErrorsMode.Off:
                        break;
                    case CustomErrorsMode.On:
                        return customErrorsSection.DefaultRedirect + "?id=" + args.Entry.Id;
                    case CustomErrorsMode.RemoteOnly:
                        if (!HttpContext.Current.Request.IsLocal)
                            return customErrorsSection.DefaultRedirect + "?id=" + args.Entry.Id;
                        break;
                }
            }

            return null;
        }
Esempio n. 4
0
        /// <summary>
        /// Raises the <see cref="Logged"/> event.
        /// </summary>
        protected virtual void OnLogged(ErrorLoggedEventArgs args)
        {
            ErrorLoggedEventHandler handler = Logged;

            if (handler != null)
                handler(this, args);
        }
Esempio n. 5
0
 public void ErrorLog_Logged(object sender, ErrorLoggedEventArgs args)
 {
     HttpContext.Current.Items["error"] = args.Entry.Error.Exception.Message;
 }
Esempio n. 6
0
        //protected void Application_Error(object sender, EventArgs e)
        //{
        //    ErrorSignal.FromCurrentContext().Raise(Server.GetLastError());
        //}  

        protected void ErrorLog_Logged(object sender, ErrorLoggedEventArgs args)
        {
            var result = ElmahErrorHandling.ProcessError(sender, args);
            if (!string.IsNullOrEmpty(result))
                Response.Redirect(result);
        }