Are static开发者_如何学C variable values the same within one session or are their values the same at application server level?
They're at an AppDomain
level - that's the same for all static variables, whether they're in ASP.NET or not.
So:
- If you use the same class from different AppDomains, you'll get separate variables
- If your AppDomain is recycled, you'll get separate variables
- If two requests go to different machines, you'll get separate variables
- If two concurrent requests hit the same AppDomain, they can mess with each other (so things like
count++
aren't safe)
I think as long as iis process is there the static variable will hold its value
The variable will still in memory until the restart of the application.
精彩评论