Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

251
Vistas
How to check the logged in users session and if they are logged in authenticated?

I have a identity validation problem I have a HTML and CSS I like to display for people logged in with a ticket number but whenever I start the application after I've closed it as a user logged in I always return as a logged in user with invalid ticket number.

<ul class="navbar-nav justify-content-end">
                        @if (HttpContext.Current.User.Identity.IsAuthenticated)
                        {
                            <li class="nav-item pt-4">
                                <a class="nav-link" aria-current="page" href="/mina-sidor/">Mina sidor</a>
                            </li>
                            <li class="nav-item pt-4">
                                @Html.ActionLink("Logga ut", "Logout", "Authentication", new { area = "" }, new { @class = "btn btn-primary" })
                            </li>
                            <li class="nav-item pt-4 px-1">
                                <p>Inloggad som <br /> <strong>@User.Identity.Name</strong></p>
                            </li>
                        }
                        else
                        {
                            <li class="nav-item pt-2">
                                @Html.ActionLink("Logga in", "Login", "Authentication", new { area = "" }, new { @class = "btn btn-primary" })
                            </li>
                        }

                    </ul>

HttpContext.Current.User.Identity.IsAuthenticated -> returns true always unless I manually log out.

I've tried Request.IsAuthenticated -> same here.

How do I handle that this return false when the website is closed or it has timed-out?

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

Have you a github or other repo to see your code?

Is the User.Identity.Name filled?

If your authentication system is based on cookie, exiting from the application the cookies aren't deleted/removed. So you need to verify if there are still there.

By default ASP.NET is configured for Session cookies. These cookies are not persistent and don't survive if you close your browser.

But if you have a persistent cookie with an expire time, like:

   theCookie.Expires = DateTime.Now.AddHours(1);

your session will survive to browser closing action.

If your authentication system is based on Session storage or Persistent storage check it via F12 - Application - Storage data.

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda