简体   繁体   中英

ASP.NET WebForms Logout not working after enabling external login

I have a problem with ASP.NET WebForms Logout. It is not working after I have enabled external logins for Google and Facebook.

Clicking the Log Off button does not fire the OnLoggingOut event in LoginStatusControl and because of that, the back-end method Unnamed_LoggingOut is not hit. After clicking the Log Off button it makes a postback and just reloads the home page. If I enter some other page and then click the Log Off button it works and successfully logs out.

I`m using the Visual Studio master page template and code behind and they are not modified.

<asp:LoginView runat="server" ViewStateMode="Disabled">
<AnonymousTemplate>
    <ul class="nav navbar-nav navbar-right">
        <li><a runat="server" href="~/Account/Register">Register</a></li>
        <li><a runat="server" href="~/Account/Login">Log in</a></li>
    </ul>
</AnonymousTemplate>
<LoggedInTemplate>
    <ul class="nav navbar-nav navbar-right">
        <li><a runat="server" href="~/Account/Manage" title="Manage your account">Hello, <%: Context.User.Identity.GetUserName()  %> !</a></li>
        <li>
            <asp:LoginStatus runat="server" LogoutAction="Redirect" LogoutText="Log off" LogoutPageUrl="~/" OnLoggingOut="Unnamed_LoggingOut" />
        </li>
    </ul>
</LoggedInTemplate>

protected void Unnamed_LoggingOut(object sender, LoginCancelEventArgs e) {
    Context.GetOwinContext().Authentication.SignOut(DefaultAuthenticationTypes.ApplicationCookie);
}

It turns out that the problem exists only when I run the app on my local machine - localhost /still no explanation why/. I have deployed the app at appharbor and login and logout are working fine.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM