Set the Thread.CurrentPrincipal
, and that will initialize the User
property in the controller automatically.
For people that see this answer, but have no idea how to set CurrentPrincipal
.:
This code is extracted from MSDN.
Thread.CurrentPrincipal = new GenericPrincipal
(
new GenericIdentity("Bob", "Passport"),
new[] {"managers", "executives"}
);