Is it possible to show the error details like error.Exception , and its some properties in a view (Error.cshtml)
Now i am able to send the mail to a specified id and shows a custome page Error.cshtm. How can i read the error details and show them on View instantly.
We can call a method like this on Global.cs and this will execute immediatly after error occurs. But how can we read details from here to view?
You can use HandleError attribute and mark action with HandleError, it will automatically handle all error for your action and redirect to Error.cshtml, with
HandleErrorInfo as model, you can use the exception property out of it in view and display.
Alternatively, you can handle the exception in Global.asax with Application's Error event and display the exception. You can find one example
here.
Both methods will work, but i am using ELMAH for error handling. So how can i show the details of error instantly on view keeping the ELMAH as it is. SInce i dont want to switch from this
I am not about exact option, but sure that you can log the error with Elmah and display the error on the UI. Also try the customError options in the web.config file.
mMATHAI
Member
2 Points
38 Posts
Showing ELMAH error details instantly in mvc3
Aug 31, 2012 05:19 AM|LINK
Is it possible to show the error details like error.Exception , and its some properties in a view (Error.cshtml)
Now i am able to send the mail to a specified id and shows a custome page Error.cshtm. How can i read the error details and show them on View instantly.
We can call a method like this on Global.cs and this will execute immediatly after error occurs. But how can we read details from here to view?
protected void ErrorLog_Logged(object sender, Elmah.ErrorLoggedEventArgs args)
{
}
Is it possible ?
Thanks
CPrakash82
All-Star
18270 Points
2839 Posts
Re: Showing ELMAH error details instantly in mvc3
Aug 31, 2012 07:29 PM|LINK
You can use HandleError attribute and mark action with HandleError, it will automatically handle all error for your action and redirect to Error.cshtml, with HandleErrorInfo as model, you can use the exception property out of it in view and display.
Alternatively, you can handle the exception in Global.asax with Application's Error event and display the exception. You can find one example here.
mMATHAI
Member
2 Points
38 Posts
Re: Showing ELMAH error details instantly in mvc3
Sep 01, 2012 10:45 AM|LINK
Both methods will work, but i am using ELMAH for error handling. So how can i show the details of error instantly on view keeping the ELMAH as it is. SInce i dont want to switch from this
CPrakash82
All-Star
18270 Points
2839 Posts
Re: Showing ELMAH error details instantly in mvc3
Sep 01, 2012 05:36 PM|LINK
I am not about exact option, but sure that you can log the error with Elmah and display the error on the UI. Also try the customError options in the web.config file.