title: Why is User (as in User.Identity.Name) null in my abstract base controller?
body: <p>I was asking a related question but messed the title up and no-one would understand it. Since I am able now to ask the question more precisely, I decided to reformulate it in a new question and close the old one. Sorry for that.</p>
  
  <p>So what I want to do is passing data (my custom user's nickname as stored in the db) to the LoginUserControl. This login gets rendered from the master page via Html.RenderPartial(), so what I really need to do is making sure that, say ViewData["UserNickname"] is present on every call. But I don't want to populate ViewData["UserNickname"] in each and every action of every controller, so I decided to use <a href="http://www.asp.net/Learn/mvc/tutorial-13-cs.aspx" rel="noreferrer">this approach</a> and create an abstract base controller which will do the work for me, like so:</p>
  
  <pre><code>public abstract class ApplicationController : Controller
      {
          private IUserRepository _repUser;
  
          public ApplicationController()
          {
              _repUser = RepositoryFactory.getUserRepository();
              var loggedInUser = _repUser.FindById(User.Identity.Name); //Problem!
              ViewData["LoggedInUser"] = loggedInUser;
          }
      }
  </code></pre>
  
  <p>This way, whatever my deriving Controller does, the user information will already be present.</p>
  
  <p>So far, so good. Now for the problem:</p>
  
  <p>I can't call User.Identity.Name because <code>User</code> is already null. This is not the case in all of my deriving controllers, so this is specific for the abstract base controller.</p>
  
  <p>I am setting the User.Identity.Name via FormsAuthentication at another place in the code, but I think this can't be the problem - afaik User.Identity.Name can be null, but not User itself.</p>
  
  <p>It looks to me like the HttpContext is not available (since also null ;-) and that I am missing a simple yet important point here. Can anyone give me some hints? I would really appreciate it.</p>