开发者

If I have a before action filter, how to set properties so they are available in actions?

开发者 https://www.devze.com 2023-02-05 20:36 出处:网络
In my actions, I want to pre-load the User object and set some other properties, all BEFORE the action loads.

In my actions, I want to pre-load the User object and set some other properties, all BEFORE the action loads.

I know there are events where I can do this, but how will these objects that I set be made available in my controller's actions once the filter fires and execution is now开发者_JAVA技巧 at the action level?

example:

public actionresult SomeAction() { string username = this.CurrentUser.username;

}


public override OnActionExecuting( forgotthesignature filterContext )
{
    this.CurrentUser = whatever;
}
0

精彩评论

暂无评论...
验证码 换一张
取 消