How do I handle uncaught exceptions in an ASP.NET MVC 3 application?

后端 未结 5 819
情书的邮戳
情书的邮戳 2020-12-29 06:27

I want to handle uncaught exceptions in my ASP.NET MVC 3 application, so that I may communicate the error to the user via the application\'s error view. How do I intercept u

5条回答
  •  遥遥无期
    2020-12-29 07:03

    Global Error Handling

    1. Add in web.config

    2. Error will be displayed on Error.cshtml which is resides in shared folder

    3. Change in Error.cshtml
        @model System.Web.Mvc.HandleErrorInfo
    
        @{
            ViewBag.Title = "Error"; }
    
    
        

    Sorry, an error occurred while processing your request.

    Controller Name: @Model.ControllerName

    Action Name : @Model.ActionName

    Message: @Model.Exception.Message

提交回复
热议问题