What is the differences between these two Properties?
I can use HttpContext.Items
instead of HttpContext.Features
to share data
HttpContext.Items
is designed to share short-lived per-request data, as you mentioned.
HttpContext.Features
is designed to share various HTTP features that allow middleware to create or modify the application's hosting pipeline. It's already filled with several features from .NET, such as IHttpSendFileFeature
.
You should use HttpContext.Items
to store data, and HttpContext.Features
to add any new HTTP features that another middleware class might need.