I have a controller that gets data based on current user that is logged in. And I would like to assign a local variable like this:
public UsergroupsCustAdminController()
{
User u = _us.GetUsers(HttpContext.User.Identity.Name).First();
this._customerID = u.CustomerID;
}
Somehow I cant get the value for current user logged in. How should I fix this? I need to use that "CustomerID" in lots of places in my controllerclass.
/M
You are trying to hook in too early. Suggest you override OnActionExecuting
and put this code in there, like this:
protected override void OnActionExecuting(ActionExecutingContext filterContext)
{
User u = _us.GetUsers(HttpContext.User.Identity.Name).First();
this._customerID = u.CustomerID;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With