Maybe someone can help me with this:
I have a set of Net 2 webservices running in IIS that store login information in HttpContext.Current.Cache.
Now the problem I have is that it works fine to retrieve the information between webservice calls, but sometimes, without doing anything more than stop debugging and restart, I get "Object reference not set to an instance of an object" error when trying to access the cache object.
I store the username and password from the "login" webservice in the cache with a GUID as the key. Then subsequent webservice calls pass in the GUID, and fetch the username and password from the cache.
Public Class CacheStructPublic userName As String
Public Class CacheStructPublic userName As String
Public userName As StringPublic password As String
Public password As StringEnd Class
End ClassPublic Shared Sub Add(ByVal userName As String, ByVal password As String, ByVal sid As String)Dim userObj As New CacheStructuserObj.userName = userName
userObj.password = password
HttpContext.Current.Cache.Add(sid.ToString, userObj, Nothing, DateTime.MaxValue, TimeSpan.FromMinutes(10), Caching.CacheItemPriority.Normal, Nothing)End Sub
Public Shared Sub Add(ByVal userName As String, ByVal password As String, ByVal sid As String)Dim userObj As New CacheStructuserObj.userName = userName
userObj.password = password
HttpContext.Current.Cache.Add(sid.ToString, userObj, Nothing, DateTime.MaxValue, TimeSpan.FromMinutes(10), Caching.CacheItemPriority.Normal, Nothing)End Sub
Dim userObj As New CacheStructuserObj.userName = userName
userObj.password = password
HttpContext.Current.Cache.Add(sid.ToString, userObj, Nothing, DateTime.MaxValue, TimeSpan.FromMinutes(10), Caching.CacheItemPriority.Normal, Nothing)End Sub
Nothing, DateTime.MaxValue, TimeSpan.FromMinutes(10), Caching.CacheItemPriority.Normal, Nothing)End Sub
End SubPublic Shared Function Lookup(ByVal sid As String) As CacheStructReturn CType(HttpContext.Current.Cache.Get(sid), CacheStruct)End Function
Public Shared Function Lookup(ByVal sid As String) As CacheStructReturn CType(HttpContext.Current.Cache.Get(sid), CacheStruct)End Function
Return CType(HttpContext.Current.Cache.Get(sid), CacheStruct)End Function
End FunctionIs the GC cleaning up that cache object somehow? Is IIS resetting somehow?