Board index » Web Programming » how to tell if code running in asp.net context?
|
KevinSheardy
|
|
KevinSheardy
|
how to tell if code running in asp.net context?
Web Programming423
I need to do some caching. If my code is running a part of asp.net then I would use caching, otherwise I'll just store my data in an object. And my question is now do I determine at run time if the code is running as part of asp.net? I know if HttpContext is not available I get an exception, but there must be a graceful way to determine it. Thank you. - |
| Marina
Registered User |
Thu Oct 14 13:32:50 CDT 2004
Re:how to tell if code running in asp.net context?
See if there is an httpcontext. If there is, use that. Otherwise store data
in the object. "Serg" <Serg@discussions.microsoft.com>wrote in message QuoteI need to do some caching. If my code is running a part of asp.net then I - |
| Serg
Registered User |
Thu Oct 14 13:45:04 CDT 2004
Re:how to tell if code running in asp.net context?
Hi Marina - my q was how do I determine that? HttpContext is a class, and
HttpContext.Current is an undefined object. I could catch exception but maybe there is a cleaner way to do this? Thanks "Marina" wrote: QuoteSee if there is an httpcontext. If there is, use that. Otherwise store data |
| bruce
Registered User |
Thu Oct 14 14:53:02 CDT 2004
Re:how to tell if code running in asp.net context?
try an if statement:
if (HttpContext.Current != null) { // we are running under asp.net } else { // we are not running under asp.net } -- bruce (sqlwork.com) "Serg" <Serg@discussions.microsoft.com>wrote in message QuoteHi Marina - my q was how do I determine that? HttpContext is a class, and - |
