I have a few middlewares before the OAuth Middleware and a few after it.
app.Use<Middleware1>
app.Use<Middleware2>
app.UseOAuthBearerTokens(OAuthOptions)
app.Use<Middleware3>
app.Use<Middleware4>
app.Use<Middleware5>
If I set something in the CallContext in Middleware1 or in Middleware2, it isn't available in Middleware3 or 4 or in any of the API controllers; whereas, if I set something in the CallContext in Middleware3 or 4, it's available in all the succeeding middlewares and the API controllers.
I guess UseOAuthBearerTokens is resetting or creating a new CallContext?? Has anyone encountered this?
I can get away from it by taking one of these approaches: 1. Use OwinContext instead of CallContext. Drawback - need to reference OWIN in all the projects that need the value set in the context. 2. In Middleware1, I can set the value in OwinContext, and in the middleware that follows the OAuth middleware, I can retrieve the value from OwinContext and reset it in CallContext
Let me know a proper solution for this.