使用ASP.NET MVC中的自定义登录页面进行Intranet Windows身份验证

时间:2017-12-26 07:46:14

标签: c# asp.net-mvc authentication windows-authentication

我们有内部和互联网用户的ASP.NET MVC应用程序(Windows身份验证)。如果用户在Intranet内打开应用程序,则需要自动登录。否则需要显示自定义登录页面,我们将手动进行身份验证。 (目前由于ntlm协商而显示401提示)。

有没有办法在ntlm 401上显示自定义登录页面。我们尝试了iis错误页面,application_endrequest和webconfig(错误页面)。什么都没有用。

1 个答案:

答案 0 :(得分:0)

在Asp.Net MVC中,您可以在web.config中使用您自己定义的html布局创建自定义错误页面,如下所示:

 <!--IIS Custom Errors-->
   <httpErrors errorMode="Custom" existingResponse="Replace">
      <remove statusCode="404" />
      <error statusCode="404" path="/CustomErrors/404.html" responseMode="ExecuteURL" />
      <remove statusCode="500" />
      <error statusCode="500" path="/CustomErrors/500.html" responseMode="ExecuteURL" />
    </httpErrors>