Update Logout Time in Database when User Close the Browser

I had a requirement to Update the time When User close the Browser instead of clicking Logout button. 
 
We can do this using Global Application Class (i.e Global.asax ).
 
First add a Global.asax in your website application.
Select your Website in Solution Exporer >> Right click and select Add New Item >> Select Global Application Class >>Click Add button.
 
You need to Import three namespaces here for accessing Connection, Command class, this is not a code behind so you have to import Namespace Using Import directive( this is just a another Directive like Page Directive ).

Following is the sample:

Global aspx page

And after that write your Update code in Session_End() Event of Global.asax file.
 
get the Current Time  and Update the Logout time in Database.

Global asax

Thank you.