griegs
griegs

Reputation: 22760

Get Logged in User in ActionFilterAttribute

I want to apply an action filter on one of my ActionResult methods.

I want to be able to pass to the ActionFilterAttribute the currently logged in user id.

Is there either a way I can pass the user to the attribute or have the attribute pick up the logged in user?

Upvotes: 1

Views: 4050

Answers (3)

Julian
Julian

Reputation: 36720

What about:

HttpContext.Current.User

Upvotes: 1

Yaur
Yaur

Reputation: 7452

Note that there are two different ActionFilterAttributes:

System.Web.Http.Filters.ActionFilterAttribute does not have an HttpContext property while System.Web.Mvc.ActionFilterAttribute does

If you are having trouble figuring out how to get the http context from within your filter its probably because you are using the wrong one.

Upvotes: 1

Related Questions