开发者

In ASP.NET MVC, why wouldn't I tack on HandleError on a base controller and be done with it?

Since HandleError is inherited by the derived Controllers, why wouldn't I just create (or have) a base controller, and apply HandleError on it so that any controllers that inherits from the base controller will automatically be handled as well?

And then I would tack on overriding HandleError开发者_C百科 on controllers and individual actions.

Can anyone think of any reason why I wouldn't want to apply HandleError to the base controller?


I know this question is old, but if you're now using MVC 3 I'd suggest using a global filter instead. See the Global Filters section of Scott Guthrie's post here


To me HandleError on a base controller is like surrounding your entire application with a try{} catch{} block. You've essentially stopped treating exceptions like exceptions made them a normal occurrence in your application.

You could only "catch" what you know may happen and not everything that may happen.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜