为什么MVC不使用Error.aspx?

时间:2022-01-21 05:56:12

I'm trying to add some security to my ASP.NET 1.0 MVC app (VB), but I can't get it to work. At the top of my controller, I've got:

我正在尝试为我的ASP.NET 1.0 MVC应用程序(VB)添加一些安全性,但我无法让它工作。在我的控制器的顶部,我有:

<HandleError()> _
Public Class HomeController

I'm overriding OnActionExecuting and throwing a SecurityException if the user is not in the proper role.

如果用户没有正确的角色,我将覆盖OnActionExecuting并抛出SecurityException。

Everything I've read states that this should by default look for Error.aspx first in the current folder (Home) then in the Shared folder. I've got Error.aspx in both folders, and all I'm getting is a "Security Exception" yellow screen of death.

我读过的所有内容都指出,默认情况下,这应该首先在当前文件夹(Home)中查找Error.aspx,然后在Shared文件夹中查找。我在两个文件夹中都有Error.aspx,而我所得到的只是一个“安全例外”黄色死亡屏幕。

What am I missing?

我错过了什么?

2 个解决方案

#1


do you have customErrors=On in your web.config

你的web.config中有customErrors = On吗?

here

#2


Do you have in your web.config? If mode="Off" or if you're accessing the site from the same box and mode="RemoteOnly", the debug page is shown instead of the error.aspx view.

你有web.config吗?如果mode =“Off”或者您从同一个框中访问该站点并且mode =“RemoteOnly”,则会显示调试页面而不是error.aspx视图。

If this is not the case, try creating an action on a controller that returns View("Error") and see what happens. I just had this problem recently and it was due to an error in the Error.aspx view itself. Rather than tell you there's a problem with the error view, the framework just goes ahead and displays the YSOD with the original error information.

如果不是这种情况,请尝试在返回View(“错误”)的控制器上创建一个操作,看看会发生什么。我最近遇到了这个问题,这是由于Error.aspx视图本身出错。而不是告诉你错误视图有问题,框架只是继续并显示带有原始错误信息的YSOD。

#1


do you have customErrors=On in your web.config

你的web.config中有customErrors = On吗?

here

#2


Do you have in your web.config? If mode="Off" or if you're accessing the site from the same box and mode="RemoteOnly", the debug page is shown instead of the error.aspx view.

你有web.config吗?如果mode =“Off”或者您从同一个框中访问该站点并且mode =“RemoteOnly”,则会显示调试页面而不是error.aspx视图。

If this is not the case, try creating an action on a controller that returns View("Error") and see what happens. I just had this problem recently and it was due to an error in the Error.aspx view itself. Rather than tell you there's a problem with the error view, the framework just goes ahead and displays the YSOD with the original error information.

如果不是这种情况,请尝试在返回View(“错误”)的控制器上创建一个操作,看看会发生什么。我最近遇到了这个问题,这是由于Error.aspx视图本身出错。而不是告诉你错误视图有问题,框架只是继续并显示带有原始错误信息的YSOD。