Session_End Breakpoint only steps first line

B

Beren

Hey,

I've got some code in my Session_End which cleans up all Session related
items from the Cache object.
I needed to store some related sessiondata in there to be able to address it
in the AuthenticateRequest event.

Now when I breakpoint the first line to test the Session_End code, it only
breaks on the first line.
A press on F11 through will just jump me out and resumes the program,
ignoring the remaining lines of code.

Does anyone know this problem ?

Regards,

Beren
 
B

Beren

Nope, it just acts as if I would just press F5 to resume again.
Apparently it happens when I address the Cache.

--------
1. Sub Session_End(ByVal sender As Object, ByVal e As EventArgs)
2. Dim sUserName As String = Session.Item("UserName").ToString()
3. If Not System.Web.HttpRuntime.Cache.Get(sUserName) Is Nothing Then
4. System.Web.HttpRuntime.Cache.Item(sUserName) = Nothing
5. System.Web.HttpRuntime.Cache.Remove(sUserName)
6. End If
7. End Sub
--------
As you see I have to access the Cache statically to be able to address it.
It bravely runs to line 3, and validates the condition, then it jumps to
line 4, but if
I press F11 I get the same problem.
Apparently addressing objects in this event handler is very fragile...
Then only thing I want to do is to remove a user object from the cache
before the session ends.
 
S

Scott Allen

Hi Beren:

Line 4 is throwing an exception. The cache does not let us store
references to Nothing or null - the Item has to contain a valid object
reference.

Calling Remove will be enough to clear the item from the cache.
 
B

Beren

Great news !
I just wanted to play completely safe when finishing objects that were in
the Cache.
The weird thing is that any exceptions in the Session_End won't give me any
notification whatsoever...

Thanks,

Beren
 
B

Beren

Do you happen to know how I can call the shared sub
FormAuthentication.SignOut in there ?
This event is really messing me up :(
 
S

Scott Allen

Hi Beren:

I don't think it would have an effect. What SignOut does is instruct
the browser to remove the forms authentication ticket (a cookie) with
a response header. Since the user isn't actually making a request when
Session_End fires, it is not possible to tell someone to drop a
cookie, know what I mean?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top