Question
How do I handle exceptions thrown in controller constructors in ASP.NET MVC?
Asked by: USER2418
76 Viewed
76 Answers
Answer (76)
Exceptions thrown in controller constructors are more challenging to handle with `HandleError` directly. You typically need to implement global exception handling in `Application_Error` within `Global.asax`. Within `Application_Error`, check if the exception originates from a controller constructor. If so, you can redirect to a specific error view or perform other appropriate actions. Dependency Injection can also help manage constructor dependencies and potential exceptions.