2008-10-15 Marek Habersack <mhabersack@novell.com>
[mono.git] / mcs / class / System.Web / System.Web.Caching / OutputCacheModule.cs
index a2d4374243b50e294b0ecda3f4f6273b9e1a68e0..03666dcbc50afa89b520a0b3aec11ce1b9edfc43 100644 (file)
@@ -216,22 +216,24 @@ namespace System.Web.Caching {
                        
                        if (prev == null) {
                                CachedRawResponse c = context.Response.GetCachedResponse ();
-                               string [] files = new string [] { };
-                               string [] keys = new string [] { vary_key };
-                               bool sliding = context.Response.Cache.Sliding;
+                               if (c != null) {
+                                       string [] files = new string [] { };
+                                       string [] keys = new string [] { vary_key };
+                                       bool sliding = context.Response.Cache.Sliding;
 
-                               context.InternalCache.Insert (key, c, new CacheDependency (files, keys),
-                                                             (sliding ? Cache.NoAbsoluteExpiration :
-                                                              context.Response.Cache.Expires),
-                                                             (sliding ? TimeSpan.FromSeconds (
-                                                                     context.Response.Cache.Duration) :
-                                                              Cache.NoSlidingExpiration),
-                                                             CacheItemPriority.Normal, response_removed);
-                               c.VaryBy = varyby;
-                               varyby.ItemList.Add (key);
+                                       context.InternalCache.Insert (key, c, new CacheDependency (files, keys),
+                                                                     (sliding ? Cache.NoAbsoluteExpiration :
+                                                                      context.Response.Cache.Expires),
+                                                                     (sliding ? TimeSpan.FromSeconds (
+                                                                             context.Response.Cache.Duration) :
+                                                                      Cache.NoSlidingExpiration),
+                                                                     CacheItemPriority.Normal, response_removed);
+                                       c.VaryBy = varyby;
+                                       varyby.ItemList.Add (key);
 #if NET_2_0
-                               cacheValue = key;
+                                       cacheValue = key;
 #endif
+                               }
                        }
                        
 #if NET_2_0