Nope, that didn't help unfortunately. Maybe I should provide a code sample illustrating what I'm trying to do:
public abstract class ApplicationController : Controller
{
private IUserRepository _repUser;
public ApplicationController()
{
_repUser = RepositoryFactory.getUserRepository();
var loggedInUser = _repUser.FindById(User.Identity.Name);
ViewData["LoggedInUser"] = loggedInUser;
}
}
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.
The problem is that I can't even call
User.Identity.Name
because User
is already null
. Seems like the HttpContext
is not available in my Application Controller, as opposed to my deriving controllers.
I think the solution must be quite simple as this is an approach described in the official MVC tutorials, only they didn't have to access User.Identity.Name at this point.
Ideas, anyone? Thanks so far.