lunargirrl
Programmer
I am creating a cache in this way:
'I found this code in the net and it is working really fine, but i have a problem: how can i remove this variables from my cache if the user clicks the "close" button in my application? (I mean the sintax to remove the str1 from cache)
here's my code:
on my login page
---------------------
Dim str1 As String = username & userid
Dim struser As String = Convert.ToString(Cache(str1))
If struser Is Nothing Or struser = [String].Empty Then
Dim SessTimeOut As New TimeSpan(0, 0, HttpContext.Current.Session.Timeout, 0, 0)
HttpContext.Current.Cache.Insert(str1, str1, Nothing, DateTime.MaxValue, SessTimeOut, System.Web.Caching.CacheItemPriority.Normal, Nothing)
Session("user") = username & userid
'then autenticate...
else
labe1.text = "Login Failure"
endif
on my global.asax
------------------------
Protected Sub Application_PreRequestHandlerExecute(ByVal sender As Object, ByVal e As EventArgs)
If Not (Session("user") Is Nothing) Then
Dim str1 As String = CStr(Session("user"))
Dim struser As String = CStr(HttpContext.Current.Cache(str1))
End If
End Sub
TIA,
Gis.
'I found this code in the net and it is working really fine, but i have a problem: how can i remove this variables from my cache if the user clicks the "close" button in my application? (I mean the sintax to remove the str1 from cache)
here's my code:
on my login page
---------------------
Dim str1 As String = username & userid
Dim struser As String = Convert.ToString(Cache(str1))
If struser Is Nothing Or struser = [String].Empty Then
Dim SessTimeOut As New TimeSpan(0, 0, HttpContext.Current.Session.Timeout, 0, 0)
HttpContext.Current.Cache.Insert(str1, str1, Nothing, DateTime.MaxValue, SessTimeOut, System.Web.Caching.CacheItemPriority.Normal, Nothing)
Session("user") = username & userid
'then autenticate...
else
labe1.text = "Login Failure"
endif
on my global.asax
------------------------
Protected Sub Application_PreRequestHandlerExecute(ByVal sender As Object, ByVal e As EventArgs)
If Not (Session("user") Is Nothing) Then
Dim str1 As String = CStr(Session("user"))
Dim struser As String = CStr(HttpContext.Current.Cache(str1))
End If
End Sub
TIA,
Gis.