我需要同时使用Windows身份验证和基本身份验证来运行IdentityServer4. 现在,当我尝试在未连接到ActiveDirectory的PC上登录IdentityServer4时,浏览器显示登录"表单,我可以在其中填写ActiveDirectory凭据. 可以.
I need to run IdentityServer4 with both Windows Authentication and Basic Authentication. For now, when I trying to login to IdentityServer4 on PC that is not connected to ActiveDirectory, browser shows Login form, where I can fill ActiveDirectory credentials. This is OK.
但是现在我需要处理在此表单上单击取消"按钮,并将其重定向到仅本地登录的HTML表单,在这里我可以使用凭据表单数据库登录(我使用.NET Core Authentication). 现在,当我单击取消"时,我被重定向到401错误站点.有可能处理吗?
But now I need to handle click Cancel button on this form, and redirect to local login only HTML form, where I can login with credentials form database (I using .NET Core Authentication). Now when I click Cancel, I'm redirected to 401 error site. Is it possible to handle?
推荐答案
我遇到了同样的情况,在我的情况下,我使用了这种中间件扩展方法
I fell in the same situation and in my case I use this middleware extension method
app.UseStatusCodePages(async context => { if (context.HttpContext.Response.StatusCode == (int)HttpStatusCode.Unauthorized) { context.HttpContext.Response.ContentType = "text/html"; await context.HttpContext.Response.WriteAsync( string.Format("<script>window.location='../account/Login{0}'</script> ", context.HttpContext.Request.QueryString)); } });更多推荐
处理取消单击Windows身份验证
发布评论