2

In C# there is a class ThreadLocal. You can use it to define a static field that only exist within the scope of a thread.

I am looking for something similar for use in an ASP Custom Control. I need to define a static field that is shared between all instances of this control, within the scope of a request.

Does there exist something out of the box for it?

Stijn Van Antwerpen
  • 1,840
  • 17
  • 42

1 Answers1

2

You can use the HttpContext.Items dictionary that is associated with each request.

In ASCX code, for example:

this.Context.Items.Add("key", value);

See Documentation

haim770
  • 48,394
  • 7
  • 105
  • 133