Michael Falconer

the difficult takes time, the impossible just a little longer

My Links

Blog Stats

News

Michael Falconer is a freelance/contract .net developer working in and around Glasgow, Scotland, mainly on asp.net applications. His company is called, for some strange reason, Camel-Jones.

Archives

Post Categories

Blogs

Other Links

Regulars

Accessing current HttpContext from a static method

I was writing a class to hadle the caching of objects for the ASP.NET application I'm currently developing, and suddenly wondered if I could access the current HttpContext from within a static method. The answer, of course, is yes..

System.Web.HttpContext context = System.Web.HttpContext.Current

Another quick and easy answer thanks to .NET 247.

UPDATE: Thanks to Scott (see comments below) for pointing out you can also access the Cache directly via the HttpRuntime class, without requiring a context.

posted on Sunday, August 29, 2004 10:49 AM