How should I store per request data when using OWI

2020-07-18 02:08发布

问题:

I'm in the process of converting my ASP.NET Web API from being IIS hosted to being self hosted.

In one of my DelegatingHandlers I set the current user based on the token from the HTTP header. I've been using HttpContext.Current.Items to store this information, but that isn't available under self hosting.

What is the correct way to store per request data that can be accessed anywhere in my application?

回答1:

The Request message has a Properties collection.