Context: .Net 3.5, C#
I\'d like to have caching mechanism in my Console application.
Instead of re-inventing the wheel, I\'d like to use System.Web.Caching.Cache>
I ended on this page wondering the same thing. Here's what I'm doing (which I don't like but seems to work just fine):
HttpContext context = HttpContext.Current;
if (context == null)
{
HttpRequest request = new HttpRequest(string.Empty, "http://tempuri.org", string.Empty);
HttpResponse response = new HttpResponse(new StreamWriter(new MemoryStream()));
context = new HttpContext(request, response);
HttpContext.Current = context;
}
this.cache = context.Cache;