0

I am working on an asp.net web-application with a session timer of 7 minutes. After 7 minutes the session expires. I am pinging the server from the client every 5 minutes and because of that the session will never time out. The ping on the service does run some code server-side.

How can I disable that these pings will renew the session timer?

Marc Trittibach
  • 371
  • 3
  • 8
  • Possible duplicate of [Asp.net session never expires when using SignalR and transport mode long polling](http://stackoverflow.com/questions/23971220/asp-net-session-never-expires-when-using-signalr-and-transport-mode-long-polling) – Asons Jan 29 '16 at 14:35

1 Answers1

0

Add a session variable to track when the session started. If the session time is over 7 min then call Session.Abandon() this will remove the session.

Public Sub ClearSession()
    If Me.Session("Started") IsNot Nothing AndAlso (DateDiff(DateInterval.Minute, CDate(Me.Session("Started")), Now())) >= 7 Then
        Me.Session.Abandon()
    End If
End Sub
JayHach
  • 194
  • 3
  • This will kill every session after 7 minutes as far I can see. If the user is actually working with the application (making requests etc.), the session should behave normal. It is just about the ping which should be ignored by the session. – Marc Trittibach Oct 30 '14 at 07:17