Reputation: 162
In HttpContext(Or some thing like this) I need to add a temperory variable from a controller which need to available through out the request processing(Request wise variable). But the HttpContext.Current.Request is readonly. If i'm adding in Items its not getting outside. How can i achieve this
Thanks & Regards Binesh Nambiar C
Upvotes: 3
Views: 6701
Reputation: 56869
You are looking for HttpContext.Items
, which is a dictionary that can be used to store items for the duration of the current request. It goes out of scope at the end of the request.
// Set
HttpContext.Items["Customer"] = customer;
// Get
var customer = HttpContext.Items["Customer"];
Upvotes: 7