处理取消单击Windows身份验证

编程入门 行业动态 更新时间:2024-10-28 20:17:15
本文介绍了处理取消单击Windows身份验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我需要同时使用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身份验证

本文发布于:2023-11-26 10:54:01,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1633742.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:单击   身份验证   Windows

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!