Ineed to write the Error Handler Helper classes for my asp.net mvc project..
can anybody give me the code how to write and where to write this Helper classes in my appliction?
and I need to use this Error to log in controller level..
I dont want to use try and catch block for each and every Actionresult in my control..
I need to use controller level?
cananybody help me out?
thanks
I can suggest you to use elmah. It is great for error logging, you can read about it from here: http://www.hanselman.com/blog/ELMAHErrorLoggingModulesAndHandlersForASPNETAndMVCToo.aspx
What I have done, and I am happy with it is the following. I have done a custom handle error attribute, which has the following code:
And I have an ExceptionHelper class with this code:
Then I have annotated my base controller class with
MyNamspace.HandleErrorand now all exceptions are handled and logged, I even get a mail when something goes wrong….