I am using ASP.NET MVC. I catch any unhandled exception on OnExceptionin BaseControllerto correctly display a nice message.
However, I have an Http Module project in the same solution. The module may throw InvalidOperationExceptionif the user makes an incorrect request. I am using IIS7 integrated mode and everything is configured correctly. I am new to IIS and the exception of the Http module.
Googling just found a way to handle exceptions using HttpMethod, which is different from this case.
The question is whether the exception was thrown in the module, will MVC execute or not? If he does, why doesn't he go to OnException? and how to get an exception in MVC, for example, in the Action method?
Edit: Based on @nickvane's answer on the application life cycle, I try to better explain the situation. I think that anyone HttpModuleeven created by me can throw any exception. I want this exception to be handled by my MVC, which is in UrlRoutingModule. I think about:
- HttpModule Order
- An unhandled exception stops the module and the next module will never start?
- How to handle an exception in a MVC (
UrlRoutingModule) web application if it was just added to another HttpModule executed before or after UrlRoutingModule. context.AllErrors context.Error? .
, , - Server.Transfer(), , , , .
: MVC Restful API, MUST JSON. MVC OnException, - { "": " ".}. HttpModule, posibbly . API JSON, . MVC JSON.