处理取消单击Windows身份验证 [英] Handle Cancel click on Windows authentication

查看:123
本文介绍了处理取消单击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身份验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆