Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Kevon K. Hayes 255 posts 281 karma points
    Aug 08, 2011 @ 21:41
    Kevon K. Hayes
    0

    Hooking into Global.asax in UMB 4.5.2

    All,

    I've read Ismail's and Matt's blogs and I still cannot get this to work.

    http://blog.mattbrailsford.com/2010/07/11/registering-an-application-start-event-handler-in-umbraco/
    http://ismailmayat.wordpress.com/2009/05/19/integrating-log4net-into-umbraco-site/

    Here's the code:

        public class corHandleErrors:umbraco.Global
        {
            public corHandleErrors()
            {
           
            }

            protected override void Application_Error(object sender, EventArgs e)
            {
                //Email Web Admin and get the referrer
                string referringPage = System.Web.HttpContext.Current.Request.ServerVariables["HTTP_REFERER"];
                Exception ex = Server.GetLastError();
                Log.Add(LogTypes.Custom, -1,String.Format("StackTrace is: {0} | Inner Exception is: {1}", ex.StackTrace, ex.InnerException));

                SmtpClient oClient = new SmtpClient();
                MailMessage message = new MailMessage();

                message.To.Add(new MailAddress("xxx"));
                message.From = new MailAddress("xxx");
                message.Subject = "UMB 4.5.2 Error";
                message.Body = String.Format("Stacktrace: {0} | InnerException: {1}", ex.StackTrace, ex.InnerException);

                oClient.Send(message);

                base.Application_Error(sender, e);
            }
        }

    I've removed the App_global.asax.dll.  Am I missing something?

     

  • Ismail Mayat 4511 posts 10091 karma points MVP 2x admin c-trib
    Aug 09, 2011 @ 13:12
    Ismail Mayat
    1

    Kevon,

    Don't inherit from umbraco.global inherit from System.Web.HttpApplication 

    Regards

    Ismail

  • Kevon K. Hayes 255 posts 281 karma points
    Aug 09, 2011 @ 13:35
    Kevon K. Hayes
    0

    I'll give it a try and let you know.

  • Kevon K. Hayes 255 posts 281 karma points
    Aug 09, 2011 @ 15:12
    Kevon K. Hayes
    0

    Inheriting from umbraco.Global and System.Web.HttpApplication works I just forgot to add the global.asax to the root of my web application.  DANG.  As soon as I added that I received the Logs and Emails as expected.

Please Sign in or register to post replies

Write your reply to:

Draft