ASP.NET MVC的HandleError观未找到 [英] ASP.NET MVC HandleError View Not Found
问题描述
我想实现的异常使用的HandleError属性在ASP.NET MVC3处理。
I'm trying to implement exception handling in ASP.NET MVC3 using the HandleError attribute.
在code,我使用看起来像这样:
The code that I'm using looks like this:
[HandleError(Order = 1, ExceptionType = typeof(SocketsOfflineException), View="EndSystemDownError")]
这工作时,EndSystemDownError视图位于共享文件夹中的预期。不过,我有一些错误的观点,我想出来分成专门为错误的文件夹,名为错误。
This works as expected when the EndSystemDownError view is located in the "Shared" folder. However, I have a number of Error views, and I want to separate them out into a folder specifically for Errors, called "Error".
所以我拉EndSystemDownError视图出的共享文件夹并进入视图文件夹错误子文件夹。然后,我更新视图属性〜/查看/错误/ EndSystemDownError
。然而,这将导致异常,说明该观点没有被发现。我试图 /查看/错误/ EndSystemDownError
为好,具有相同的结果。
So I pull the EndSystemDownError view out of the shared folder and into an "Error" subfolder in the Views folder. I then update the View property to ~/Views/Error/EndSystemDownError
. This however results in an exception stating that the view was not found. I tried /Views/Error/EndSystemDownError
as well, with the same results.
我曾尝试加入 ErrorController
与 EndSystemDownError
的行动,无论是作为一个故障排除措施,因为我会喜欢一些控制器功能添加到视图。这有没有影响。
I have tried adding an ErrorController
with an EndSystemDownError
action, both as a troubleshooting measure, and because I would like to add some controller functionality to the view. This has no effect.
我似乎无法找出我做错了什么。也许这是MVC中的错误,也可能是不支持共享文件夹,这将是令人失望的错误以外的意见。
I can't seem to figure out what I'm doing wrong. Perhaps this is a bug in MVC, or maybe it doesn't support error views outside of the Shared folder, which would be disappointing.
推荐答案
如果你把你的错误,子文件夹的共享文件夹内,你可以参考它通过错误/ whatevererror.aspx,它应该是罚款。
If you put your errors subfolder inside of the shared folder, you can refer to it by Errors/whatevererror.aspx and it should be fine.
我经常这样做。毕竟他们是共同的看法。 :)
I do this frequently. After all they are shared views. :)
这篇关于ASP.NET MVC的HandleError观未找到的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!