.net - ThreadLocal in combination with IHttpModule -


i have been playing around in webproject in httpmodule prepare data different classes on later stage should work.

would safe expose data in public static accessable threadlocal storage?

ie.

public static threadlocal<a> storage = new threadlocal<a>();  private void application_beginrequest(object source, eventargs ) {     storage.value = new a(); } 

my initial test shows code executed in controllers etc. works on same thread above snippet module executed in.

ie.

public actionresult index() {     var o = module.storage;     if (o.isvaluecreated)     {         // worx     }     return view(); } 

but not find documentation ensured me guaranteed behaviour.

would work? or should behaviour in other way?

(needless threads spin myself on later state loose connection tls.)


Comments