同个iis内的不同站点能跨站共享吗?

解决方案 »

  1.   

    cache是应用程序的cache,所以不能跨应用程序使用
      

  2.   

    可以采用依赖文件的方式(多个web程序依赖同一个文件作cache),请看下面的参考代码public override void SetCache( Common.CacheType cacheType, object value )
    {
    SetPastExpiration( cacheType ); Context.Cache.Insert( cacheType.ToString(), value, GetCacheDependency(cacheType) );
    } public override void SetPastExpiration( Common.CacheType cacheType )
    {
    string filePath = GetFilePath( cacheType ); if ( File.Exists(filePath) )
    {
    lock ( filePath )
    {
    File.SetLastWriteTime( filePath, DateTime.Now );
    }
    }
    }