ASP.NET MVC OnException-是否尝试捕获? [英] ASP.NET MVC OnException - Try catch required?

查看:48
本文介绍了ASP.NET MVC OnException-是否尝试捕获?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是MVC ASP.NET的新手.我阅读了有关OnException重写方法的信息.我在想,是否应该在Controller或Model上放置try catch {throw}以便调用OnException.或者,我尝试不要求catch,如果发生任何异常,会自动调用OnException吗?

I'm pretty new to MVC ASP.NET. I read about OnException override method. I'm thinking, whether I should put try catch {throw} on Controller or Model in order for OnException to be invoked. OR, I try catch not required, OnException will be invoked autmatically if any exception occurs?

感谢堆.

推荐答案

在操作中发生未处理的异常时调用."

"Called when an unhandled exception occurs in the action."

http://msdn.microsoft.com/en-us/library/system.web.mvc.controller.onexception.aspx

如果您不处理(即捕获")异常,则应调用OnException方法.

If you don't handle (i.e. "catch") an exception, the OnException method should be called.

这篇关于ASP.NET MVC OnException-是否尝试捕获?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆