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 7505895
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T22:04:36+00:00 2026-05-29T22:04:36+00:00

I have 2 controllers. A HomeController and an AccountController . I have a _Layout.cshtml

  • 0

I have 2 controllers. A HomeController and an AccountController. I have a _Layout.cshtml and a partial view _Login.cshtml that gets rendered in the header section of the _Layout view. The HomeController has the default Index() method.

The very first time, the user sees Have an Account? Log In. Log In is a link that points to the Login method in the AccountController. The Logon view contains UserName, Password fields, and a Check box for Remember me. When the user logs in for the first time and has the Remember me checked, I call my MySecurityRepository to: validate the user and go get basic info for their profile (address, phone number, email, etc..) and the UserInfo object is populated and the header shows the UserName as a link. This all works.

The user closes the browser and reopens the site. I see the user is already logged in, Request.IsAuthenticated is true, but how do I go about retrieving the user’s profile again and caching?

Here is what the _Login partial view looks like…

 <div id="login">
 @if (Request.IsAuthenticated)
 {
     <text>
         [@Html.ActionLink((HttpContext.Current.Session["UserInfo"] as UserInfo).FirstName, "Profile", "Account")]
         [@Html.ActionLink("Log Off", "LogOff", "Account")]
     </text>
 }
 else
 {
     <span>Have an account?</span>
     @Html.ActionLink("Log In", "LogOn", "Account")
 } </div>

Thanks.

  • 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-29T22:04:41+00:00Added an answer on May 29, 2026 at 10:04 pm

    You will have to fetch the user information from the backend if it is not available. For this you could write a child action that will first look at the session and if it is not available there fetch it and store it inside. Then you could include this child action in the _Layout using the Html.Action helper.

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

Sidebar

Related Questions

I have two view controllers that allow changes to the Address Book. The first
I have a HomeController with an Index action that shows the Index.aspx view. It
I have a partial view that is been used in several places in the
In my ASP.Net MVC app, I have the following controllers HomeController ExController ExController has
I have two view controllers in a tabbar which can both edit data. Therefore,
I have two view controllers name RootViewController and SecondViewController. In the FirstViewController I have
Does anyone have any code examples on how to create controllers that have parameters
I have a list of actions on various controllers that are 'Admin' functions (create,
I have an application that has an public 'end user' mode and a 'back
I have created an otherwise empty ASP.NET MVC 3 application with 2 controllers, HomeController

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.