Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET WebForms
I'm looking for a server-side variable that only lives for the duration of a single request and that gets reset each request, and that is shared between multiple control instances, and that is specific to each user (rather than shared among multiple users).
 
A static variable persists too long (across multiple requests), a member variable isn't shared among multiple control instances, session persists across multiple requests, and cookies/view state go to the client (I only want it to reside on the server).
 
I could probably store something in session and reset it in Application_BeginRequest so that it is fresh for each request (and maybe erase it in Application_EndRequest), but I was wondering if there was a more standard way of doing this. How would you create such a variable?
Posted 11-Jan-13 7:55am
AspDotNetDev191.5K
Comments
AspDotNetDev at 11-Jan-13 14:16pm
   
Not sure what you mean, but any variable (member or static) on the class for a given page would not work because it should be accessible from any control (and controls should have no knowledge of the specific page they are on, because they may reside on many pages). Though, maybe if I put it on the page and passed a delegate to the control so it knows how to get/set the page variable, that'd work. Seems complicated though.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 275
1 OriginalGriff 230
2 BillWoodruff 173
3 CPallini 155
4 Kamal Rocks 144
0 OriginalGriff 5,655
1 DamithSL 4,506
2 Maciej Los 3,997
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,180


Advertise | Privacy | Mobile
Web01 | 2.8.141216.1 | Last Updated 11 Jan 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100