我试图理解错误处理在MVC预览使用授权[授权]操作过滤器时,是如何工作的4ASP.Net MVC授权行为过滤
我有一个看起来像这样的动作:
[Authorize(Roles = "DOMAIN\\NOTAUTHORISED_ROLE")]
[HandleError]
public ActionResult NeedAuthorisation()
{
throw new NotImplementedException();
}
当我访问网址:http://localhost:2197/testAuthorisation/NeedAuthorisation
时,我在浏览器中得到一个空白页面。在Firebug中,我可以看到发出了一个请求,并返回了401 - Unauthorised
的响应状态。但我没有被重定向或返回customError。使用我获得授权的角色时,一切都按预期工作。
这是使用Windows身份验证。我正在编写一些代码来尝试表单身份验证,看看我是否得到相同的问题。 我有<customerrors mode="On"/>
集,并在testAuthorisation文件夹和共享文件夹中创建了错误页面。
谢谢,但我已设置customErrors。这不是帮助 – Lewis 2009-01-29 13:36:14