tags:

views:

40

answers:

2

Hello

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

+2  A: 

You are trying to hook in too early. Suggest you override OnActionExecuting and put this code in there.

David M
You have some example where it shows how I can pass that variable in?
molgan
belugabob
@belugabob - Absolutely right, and I am a stickler for this myself. Not a clue how that got through (if you check my list of edits you'll see many spelling, grammar and punctuation fixes). +1 for catching me out. :)
David M