我正在使用 asp.net 3.5 web.config 来限制访问,效果很好。
<authentication mode="Windows">
<authorization>
<allow users="Bill, John"/>
<deny users="*"/>
</authorization>
系统错误消息将阻止未经授权(但经过身份验证)的用户:
Server Error in '/' Application
Access is denied.
Description: An error occurred while .......
Error message 401.2: Unauthorized: Logon failed due to server configuration ...
为了使消息更友好,我取消注释 customErrors 标志并在我的项目的根路径中创建一个 GenericErrorPage.htm。
<customErrors mode="On" defaultRedirect="GenericErrorPage.htm">
<error statusCode="403" redirect="NoAccess.htm" />
<error statusCode="404" redirect="FileNotFound.htm" />
</customErrors>
但是,它只是行不通。我仍然收到系统错误消息,而不是我的自定义错误页面。
任何建议将不胜感激。