tags:

views:

25

answers:

2

I have created a public List that is runs and is accessed from my a Web Application.

private static List<x> _x;
static readonly object lockObjx = new object();

public static void XCache()
{
            if (_x != null)
                return;

            lock (lockObjx)
            {
               _x = GetFromDatabase();
            }
}

This all runs happily under the default app pool. I now need to add a web service that can update the this cache. Will I be able to do this running on the default app pool? If not is there a way I can do this without installing something like MEMCache. The Service and and Wepp run on the same server.

A: 

Yes, yo ucan do that on the default app pool. Why should you not?

TomTom
A: 

In order to make that work, you need to put the service in the same ASP .NET Application as the web application. This usually means running them in the same Site in IIS.

Each ASP .NET Application gets its own AppDomain. Each AppDomain has it's own copy of all objects, including static references. In other words, data is not shared between AppDomain's, and hence is not shared by individual applications in IIS, even if they are running in the same IIS process (AppPool).

There's a nice article here: http://odetocode.com/Articles/305.aspx. It might be a bit old, but it should still be valid.

driis