Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6571777
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T14:55:28+00:00 2026-05-25T14:55:28+00:00

I have a problem with the user Login and Logout in an MVC3 application.

  • 0

I have a problem with the user Login and Logout in an MVC3 application. Here’s an example of my logout actions in my user controller:

public ActionResult Logout()
{
    FormsService.SignOut();
    Session.Clear();
    return RedirectToAction("index", "home");
}

Once a user clicks Logout this action is called, it clears the session information and then the user is redirected to the index page.

On my index page I call a C# helper to display a message like this:

@section links { @Html.HdrLinks("Home", "", Context.User) }

Here’s part of the code of the helper:

System.Security.Principal.IPrincipal user

if (user.Identity.IsAuthenticated)
{
   return new MvcHtmlString("Welcome " + user.Identity.Name);
}

My problem is that when the index page displays IMMEDIATELY AFTER the logout it still shows the same session information. In other words it still shows a message like “Welcome John”. Only AFTER I refresh the page in the browser does it correctly see that there user name is not set in the session.

Does anyone have any ideas on what I can do to make it so that after a logout and a redirect then the index page does not still think the user is logged in? For example is there some call other than RedirecToAction that I could execute that would help me.

UPDATE:

It would seem that when I change my code to the following then it does what I want and when it gets to display the index page then it does not show me I am still logged in. However I am not sure why this works.

FormsService.SignOut();
Session.Clear();
Session.Abandon();
return new RedirectToRouteResult(new RouteValueDictionary(new { controller = "Home", action = "Index" }));
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T14:55:29+00:00Added an answer on May 25, 2026 at 2:55 pm

    It might be a cache problem. Have you checked that when your code ask a browser to make redirect then the browser really makes a new request to the index page? Just set a breakpoint at index action and take a look to Session property.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

On my website I want the user to have the ability to login/logout from
Let's say I have a SessionsController , which controls user login and logout, but
i am working on a asp.net(with c#) web application and here i have problem.
I have a asp.net web application, that allows users to login and logout. When
I have a problem with the MySQL root user in My MySQL setup, and
I have a problem regarding getting the path of a user control. The scenario
I have a bit of a problem with user controls. Basically what I want
I have a problem for querying records into mysql explanation below The user could
I have a problem that i cant solve :( I have a user control
i still have a problem to develop a convenient app to the user. because

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.