1

I created a REST service using WebAPI 2. I then created a Windows service to wrap the API.

In WebAPI project, there were a couple of places I was using HttpContext.Current.Items dictionary to persist some metadata (during authentication) to avoid a second call to the DB later on in the request.

From what I understand, HttpContext.Current does not exist in OWIN. What I am trying to figure out is how I should persist data for only one request cycle.

  • Is there a way to do this out of the box or is there a library that would provide what I need?
  • Should I just roll my own?
Brian
  • 6,910
  • 8
  • 44
  • 82
  • Look at this post http://stackoverflow.com/questions/19192428/server-side-claims-caching-with-owin-authentication – 0leg Apr 18 '14 at 15:02
  • @0leg, thanks for the link. I looked at some of the forms/cookie based auth stuff OWIN provides, but that's really not what I am looking to do. I don't need to persist data between requests, only in the same request – Brian Apr 18 '14 at 16:03

1 Answers1

0

What about the Properties collection of HttpRequestMessage? You can store per-request objects in this dictionary.

http://msdn.microsoft.com/en-us/library/system.net.http.httprequestmessage.properties(v=vs.118).aspx