Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8641837
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T11:37:57+00:00 2026-06-12T11:37:57+00:00

I’ve been scanning forums for an implementation of the Exception Management Application Block (EMAB)

  • 0

I’ve been scanning forums for an implementation of the Exception Management Application Block (EMAB) in an ASP.NET MVC (MVC3) application.

There’s a lot of talk about ELMAH and NLog as well as handling via the global.asax (http://s151.codeinspot.com/q/694875) Vs an ErrorController (http://www.davidjuth.com/asp-net-mvc-error-handler.aspx) approach as well as leveraging the [HandleError] decoration

We are looking at standardising our Exception Management of our MVC apps with EMAB but I can’t seem to find any specific examples that provide an all round solution.

Does anyone have any links or can explain exactly how you might utilise EMAB within the MVC framework

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T11:37:58+00:00Added an answer on June 12, 2026 at 11:37 am

    I decided on the approach below…

    //**In Global.asax

        protected void Application_Error(object sender, EventArgs e)
        {
            Exception originalError = Server.GetLastError();
            Exception replacedError;
    
            if (ExceptionPolicy.HandleException(originalError, "Global Policy", out replacedError))
            {
                Exception ex = replacedError ?? originalError;
                if (ex.InnerException != null)
                {
                    ex = ex.InnerException;
                }
                var httpException = ex as HttpException;
                HttpApplication httpApplication = this.Context.ApplicationInstance;
    
                string message = Utility.GetFullMessage(httpApplication, ex, "::");
                string messageHtml = Utility.GetFullMessage(httpApplication, ex, "<br/>");
    
                LogEntry logEntry = new LogEntry();
                logEntry.EventId = 100;
                logEntry.Priority = 2;
                logEntry.Message = ex.Message + "::" + message;
                Logger.Write(logEntry);
    
                Response.Clear();
                Server.ClearError();
    
                var routeData = new RouteData();
                routeData.Values["controller"] = "Error";
                routeData.Values["action"] = Constants.ErrorGeneralKey; //"General"
                routeData.Values["message"] = ex.Message;
                routeData.Values["fullMessage"] = messageHtml;
                Response.StatusCode = 500;
    
                if (httpException != null)
                {
                    Response.StatusCode = httpException.GetHttpCode();
    
                    switch (Response.StatusCode)
                    {
                        case 403:
                            routeData.Values["action"] = "Http403";
                            break;
    
                        case 404:
                            routeData.Values["action"] = "Http404";
                            break;
    
                        default:
                            routeData.Values["httpStatusCode"] = Response.StatusCode;
                            break;
                    }
                }
                IController errorController = new ErrorController();
                var rc = new RequestContext(new HttpContextWrapper(Context), routeData);
                errorController.Execute(rc);
            }
        }
    

    //**In helper class

        public static string GetFullMessage(HttpApplication httpApplication, Exception ex, string delimiter)
        {
            return "StackTrace: " + ex.StackTrace
                        + delimiter + "User: " + ((httpApplication.User == null) ? "<null>" : httpApplication.User.Identity.Name)
                        + delimiter + "Data: " + GetExceptionData(ex.Data)
                        + delimiter + "Version: " + httpApplication.Request.Browser.Version
                        + delimiter + "Browser: " + httpApplication.Request.Browser.Browser
                        + delimiter + "Major Version: " + httpApplication.Request.Browser.MajorVersion.ToString()
                        + delimiter + "Minor Version: " + httpApplication.Request.Browser.MinorVersion.ToString()
                        + delimiter + "Javascript Version: " + httpApplication.Request.Browser.JScriptVersion.ToString()
                        + delimiter + "Ecma Script Version: " + httpApplication.Request.Browser.EcmaScriptVersion.ToString()
                        + delimiter + "Platform: " + httpApplication.Request.Browser.Platform
                        + delimiter + "Source: " + ex.Source
                        + delimiter + "Form: " + httpApplication.Request.Form.ToString()
                        + delimiter + "QueryString: " + httpApplication.Request.QueryString.ToString()
                        + delimiter + "TargetSite: " + ex.TargetSite;
        }
    

    //**In Error controller

        public ActionResult General(string httpStatusCode, string message, string fullMessage)
        {
            errorViewModel.RootCause = Enums.RootCause.General;
            errorViewModel.HttpStatusCode = httpStatusCode;
            errorViewModel.Message = message;
            errorViewModel.FullMessage = fullMessage;
            return View("Error", errorViewModel);
        }
    
        public ActionResult Http404()
        {
            errorViewModel.RootCause = Enums.RootCause.NotFound;
            return View("Error", errorViewModel);
        }
    
        public ActionResult Http403()
        {
            errorViewModel.RootCause = Enums.RootCause.Forbidden;
            return View("Error", errorViewModel);
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I know there's a lot of other questions out there that deal with this
I have an MVC Razor view @{ ViewBag.Title = Index; var c = (char)146;
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.