How to logout complete?

Hi, How I can logout in my application?
At the moment If I click “logout” in my app (c#), I can login automatically without edit the credentials. How I can disable this? The user should always edit the credentials after logout. Is there maybe an example?
Thanks in advance!

Hi @wojku,

Welcome to the Community!

There is a Windows Universal App C# Quickstart application that may serve as an example:

In the example app, it looks like to log out the user, you call await client.LogoutAsync(); like this:

private async void LogoutButton_Click(object sender, RoutedEventArgs e)
        {
            BrowserResultType browserResult = await client.LogoutAsync();
            if (browserResult != BrowserResultType.Success)
            {
                resultTextBox.Text = browserResult.ToString();
                return;
            }
            // Hide logout button
            logoutButton.Visibility = Visibility.Collapsed;
            // Display login button
            loginButton.Visibility = Visibility.Visible;
            // Clean up form
            resultTextBox.Text = "";
            connectionNameAutoSuggestBox.ItemsSource = _connectionNames;
            audienceTextBox.Text = "";
        }
3 Likes

Hello, what about
await HttpContext.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme);
?
This code is from your examples, but it doesn’t work. Should I logout i another way? What about the cookie? Should I delete them manually?
Thanks!

1 Like

Oh, I see! I was providing code for Windows Universal App C#, but await HttpContext.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme); is .NET (sorry, JavaScript/Python dev here :sweat_smile:!)

Here is the ASP.NET Core v3.1 quickstart: https://auth0.com/docs/quickstart/webapp/aspnet-core-3/01-login (.NET and .NET v2 Core are also available here: Auth0 Regular Web App Quickstarts)

Here is information from the GitHub README that explains how to log out users: auth0-aspnetcore-mvc-samples/README.md at 8c75f0ed593589f2822f43969d89f6a7b020e0d4 · auth0-samples/auth0-aspnetcore-mvc-samples · GitHub

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.