我们有带有内部和互联网用户(Windows 身份验证)的 ASP.NET MVC 应用程序。如果用户在内网打开应用程序,需要自动登录。否则需要显示自定义登录页面,我们将在其中手动进行身份验证。 (目前由于 ntlm 协商显示 401 提示)。
有没有办法在 ntlm 401 上显示自定义登录页面。我们尝试了 iis 错误页面、application_endrequest 和 webconfig(错误页面)。没有任何结果。
最佳答案
在 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>
关于c# - 使用 ASP.NET MVC 中的自定义登录页面进行 Intranet Windows 身份验证,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47975469/