Authentication 在asp.net应用程序中使用windows身份验证

Authentication 在asp.net应用程序中使用windows身份验证,authentication,redirect,error-handling,custom-error-pages,Authentication,Redirect,Error Handling,Custom Error Pages,我有一个内部网应用程序,它使用windows身份验证来获取用户名,然后将应用程序用户设置为在应用程序数据库中找到的用户。如何验证应用程序数据库中是否存在该用户,然后提供自定义错误页 在尝试使用数据库中找不到的用户登录intranet应用程序时,我收到statusCode 500内部服务器错误,但尽管设置了自定义错误并尝试重定向到特定页面,我还是收到一个奇怪的错误,url更改为: http://servername:82/NotFound.cshtml?aspxerrorpath=/ 在我的we

我有一个内部网应用程序,它使用windows身份验证来获取用户名,然后将应用程序用户设置为在应用程序数据库中找到的用户。如何验证应用程序数据库中是否存在该用户,然后提供自定义错误页

在尝试使用数据库中找不到的用户登录intranet应用程序时,我收到statusCode 500内部服务器错误,但尽管设置了自定义错误并尝试重定向到特定页面,我还是收到一个奇怪的错误,url更改为:

http://servername:82/NotFound.cshtml?aspxerrorpath=/
在我的web配置中,我有:

<authentication mode="Windows" />
<authorization>
  <deny users="?"/>
</authorization>

在system.web中,我尝试过:

<customErrors mode="On" defaultRedirect="~/Views/Shared/NotRegistered.cshtml" />

并尝试:

<customErrors mode="On" 
  <error statusCode="401" redirect="~/Views/Admin/NotFound.cshtml" />
  <error statusCode="402" redirect="Error.cshtml" />
  <error statusCode="403" redirect="Error.cshtml" />
  <error statusCode="404" redirect="Error.cshtml" />
  <error statusCode="500" redirect="NotFound.cshtml" />
</customErrors>

<authentication mode="Forms">
  <forms loginUrl="~/Account/Login" timeout="2880" />
</authentication>
<authorization>
  <deny users="?"/>
</authorization>