Link to home
Start Free TrialLog in
Avatar of anugrah
anugrahFlag for India

asked on

session_end() of global.aspx does not execute on session.abandon() in vb.net code behind

hello everybody,

friends i am working on an application where i have to reset a flag in databse by a sql query whenever the session of a user is destroyed due to timeout or proper logout, so i used session.abandon() command in vb.net code behind and write the following code in session_en() function of global.aspx .


-----------------------------------------------------------------------------------------------
 Sub Session_End(ByVal sender As Object, ByVal e As EventArgs)

        Dim connLogin As SqlConnection = New SqlConnection
        connLogin = New SqlConnection(ConfigurationSettings.AppSettings("ConnectionString"))
        If connLogin.State = ConnectionState.Closed Then
            connLogin.Open()
            Dim x = 17 'Session("IID")
            Dim cmdUpdate As SqlCommand = New SqlCommand("update status set Flag='1' where IID='" & x & "'", connLogin)
            cmdUpdate.ExecuteNonQuery()
            connLogin.Close()
            Context.Response.Write("database restored")
        Else
            Context.Response.Write("database cant be restored")
        End If

End Sub
-----------------------------------------------------------------------------------------------------

but any part of this function is not executed at all whenever session expires.

i have also given the session timeout value to 2 minutes in web.config file.

please help that exactly when and how this function can be executed as i need it at many more places.

thanks in advance.
Avatar of raterus
raterus
Flag of United States of America image

ASKER CERTIFIED SOLUTION
Avatar of softsolvers
softsolvers

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of anugrah

ASKER

ya , softsolvers , thanks a lot your soluted helped me out of your problem