I have set up an authentcation middleware (JWT Token), which I want to set user id for the request in my controller. e.g. I want to get out the data for a specific person, I want to verifiy in my token and get out the user. In the user object I have an userid which I want to put in http context, so when it goes to the request, it will use the http context with the userid to retrieve the data for the user.

How can I do that?

Would an extension method for the HttpContext benefit you here?
​public static class HttpContextExtensions {
public static UserClass GetUser(this HttpContextBase context)
{
return DecryptJwtTokenAndVerifyUser(context.Request.Headers["Authorization"]).Result;
}
}

Then you could call the extension method in your controller on the HttpContext.Current from the Request…

source