确定控制器的 OnException 中的结果类型
我正在开发一个 MVC.NET 2.0 项目,我试图在控制器的 OnException 方法中放入一些特殊的错误处理逻辑。基本上,我希望能够确定引发未处理异常的控制器方法的结果类型,以便我可以根据类型以某种格式返回错误数据(JsonResult 为 json,ActionResult 为 html)。谁能指出一种确定该类型的方法?我将非常感谢任何帮助。
提前致谢
I'm working on an MVC.NET 2.0 project where I'm trying to put in some special error handling logic in the OnException method of the controller. Basically I want to be able to determine the result type of the controller method in which the unhandled exception was raised, so that I can return error data in a certain format dependent upon the type (json for JsonResult and html for ActionResult). Can anyone point me to a way to determine that type? I would greatly appreciate any help.
Thanks in advance
假设您没有更改默认路由:
祝您好运!
Assuming you didn´t change the default routing:
Good luck!