6

I'd like to implement a counter in global.asax so I can do a giveaway on my site every xxx visits. The question is, if my page is served from the ASP.NET cache, will the counter still update?

Thanks in advance

Phil
  • 1,719
  • 6
  • 21
  • 36

1 Answers1

3

Application_OnStart this event fires only once when you application started. To implement counter you should use Session_Start event. In this event increment counter.

Amit
  • 21,570
  • 27
  • 74
  • 94
  • Thomas, thanks for the correction. But the question still stands: will Session_Start fire when a page is being served from the cache? – Phil May 19 '11 at 12:28
  • @Shraga18: if you are using session_start event then your counter will increment when a new session will be created. So cache is not going to effect counter, only new session creation will increase it. – Amit May 19 '11 at 12:33
  • So a new session only gets started when the aspx page is requested? Is there any other event I could use which would work when a page is requested from cache? – Phil May 19 '11 at 18:48