开发者

ASP.NET binding object to Request in asp.net mvc

开发者 https://www.devze.com 2022-12-22 18:39 出处:网络
I\'ve created a object that I\'d like to have accessible from wherever the request-object is accessible, and to \"die\" with the request, more or less like how you always in a mvc-appli开发者_Python百

I've created a object that I'd like to have accessible from wherever the request-object is accessible, and to "die" with the request, more or less like how you always in a mvc-appli开发者_Python百科cation has access to the RouteData-collection. Especially it's important that I have access to this object in the execution of action-filters. And also there need to be created a new object of my class whenever a new request is made to the page (the object needs to be request-safe, ie. only one request modifies that one object).

Any thoughts about how to achieve this?


HttpContext is a good place for this. The Items dictionary could be used to store objects relative to the request.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号