What is an analog of request.Properties in ASP.NET 5

≯℡__Kan透↙ 提交于 2019-12-30 23:48:34

问题


In WebApi2 it was common to put arbitrary objects into HttRequestMessage.Properties. Usually it was doing with extension-methods like request.SetUserRights() where SetUserRights just put an object into request.Properties[HttpPropertyKey.UserRights].

Now in ASP.NET 5 there is no such property in HttpRequest.

What pattern is supposed to be be used for passing arbitrary objects along with http request?

In WebApi for putting objects in request.Properties filters were used usually. We still have filters in AspNet5, so the question can be rephrased as: where should a filter put common data specific for the request. Examples of such data can be: current user's roles, current user's language and so on.


回答1:


HttpContext class has Items property which you can use for this purpose.



来源:https://stackoverflow.com/questions/29706923/what-is-an-analog-of-request-properties-in-asp-net-5

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!