|
|
||||||
|
#1
|
|
|
|
|
In a standalone module (VB) behind my asp.net application, I have a couple
of utility routines that do a simple (fixed) data-retrieval (eg. "select permissions from tblusers where userid=" & thisuser. I figured I'd be smart and save multiple db calls for the same page request by doing: Function GetPerms() as string Static myperms as string if myperms="" then {get value from db} myperms=valueFromDb 'store the retrieved data in a Static variable for use on the next request else GetPerms=myperms endif End Function Well, blow me down, I find that the static values persist across different page requests - even across multiple browser-sessions!!! Can someone please enlighten me as to what's goin on here? Thanks, Paul. |
|
|
|
#2
|
|
|
|
|
There isn't too much enlightening to do...that's what static is.
It isn't tied to a page request, or a specific user...instead it's tied to the application domain...You can read more from: http://www.panopticoncentral.net/arc...04/19/964.aspx Without knowing much more about what ur doing, I think you'd typically you'd use something like the HttpCache or Session for what you are trying to do... Karl |
|
#3
|
|
|
|
|
Hi,
for some reason static variables in asp.net have application-wide scope. It's almost the same as Application("myperms"). You could rewrite your code: Private myperms as string Function GetPerms() as string if myperms="" then {get value from db} myperms=valueFromDb 'store the retrieved data in a Static variable for use on the next request else GetPerms=myperms endif End Function Dr. Jones On Mon, 2 May 2005 20:54:37 -0400, Paul W <qqq> wrote: [..] |
|
|
| Similar Threads | |
| Really nobody knows? ISA 2000 and static routing I have SBS 2003 with ISA2000 and there are 3 network cards, one for Internet, second for LAN and third for traffic to other company. Everything is working OK, users can... |
|
| non-static method split(java.lang.String) cannot be referenced from a static context I have something similar to the following code in one of my packages: public class Blah { public static final String MoreBlah(String cExpression) { // Block empty and... |
|
| Nebie: Non-static method wait(long) cannot be referenced from a static context ??? When submiting code with Jcreator, I get back a compiler error from line 81, which is underlined. Using "thread.sleep" did not work either. What am I... |
|
| Please help: Non-static method wait(long) cannot be referenced from static context submiting code with Jcreator, I get back a compiler error from line 81, which is underlined. Using "thread.sleep" did not work either. What am I... |
|
|
All times are GMT. The time now is 07:01 PM. | Privacy Policy
|