按钮身份验证重定向不起作用

时间:2020-06-17 11:35:33

标签: asp.net authentication redirect extjs owin

我正在为现有的Webforms应用程序实现owin身份验证。

我正在尝试使登录按钮将用户重定向到Microsoft身份验证。

这是我的LoginPage.aspx.cs中的方法:

protected void LoginClicked(object sender, DirectEventArgs e)
       {
           if (!Request.IsAuthenticated)
           {
               HttpContext.Current.GetOwinContext().Authentication.Challenge(
               new AuthenticationProperties { RedirectUri = "/" },
               OpenIdConnectAuthenticationDefaults.AuthenticationType);
           }
       }

这是我在LoginPage.aspx中的按钮:

<ext:Button ID="LoginButton" runat="server" MarginSpec="40 0 0 0" Text="Log in with Microsoft" Scale="Large" AnchorHorizontal="100%" IDMode="Static" Cls="loginBtn">
                                <DirectEvents>
                                    <Click OnEvent="LoginClicked">
                                    </Click>
                                </DirectEvents>

但是,当我尝试单击该按钮时,我的站点只是刷新而没有任何反应。我还尝试将身份验证挑战添加到PageLoad中。这有效。但是该按钮不起作用。有什么想法吗?

1 个答案:

答案 0 :(得分:0)

我修复了它。我必须将AutoPostBack="True"作为属性添加到按钮中。