473,386 Members | 1,720 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Save settings on exit

Hi all,

I have been trying to save some user settings when my web application
closes, but with little success. What I want to do is start a counter on
startup, and write the total count to a database when the user logs off, or
when the user closes the web browser. My problem is that I can't seem to
catch the 'close web browser' event, to write the counter. I've tried to use
the Session_End handler in global.asax, but that doesn't seem to work.

Any ideas?

Thanks,

Jaco
Nov 18 '05 #1
3 1652
Howdy,

There's no server-side event which fires when the user closes the web
browser. The only way to do this, is to catch when the browser is closed
using client side code, and execute a server side page accordingly.

Hope this helps,

Mun

"Jaco Bregman" <so*****@microsoft.com> wrote in message
news:O7**************@TK2MSFTNGP11.phx.gbl...
Hi all,

I have been trying to save some user settings when my web application
closes, but with little success. What I want to do is start a counter on
startup, and write the total count to a database when the user logs off, or when the user closes the web browser. My problem is that I can't seem to
catch the 'close web browser' event, to write the counter. I've tried to use the Session_End handler in global.asax, but that doesn't seem to work.

Any ideas?

Thanks,

Jaco

Nov 18 '05 #2
Now, Id' surely like to know how the browser is supposed to send a request
when it is closing. The only reliable way to snag the end of the browser
session is with the Session_OnEnd event.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
http://www.takempis.com
Big Things are made up of
Lots of Little Things.

"Munsifali Rashid" <mun@**RemoveToReply**vefuk.com> wrote in message
news:OF**************@TK2MSFTNGP09.phx.gbl...
Howdy,

There's no server-side event which fires when the user closes the web
browser. The only way to do this, is to catch when the browser is closed
using client side code, and execute a server side page accordingly.

Hope this helps,

Mun

"Jaco Bregman" <so*****@microsoft.com> wrote in message
news:O7**************@TK2MSFTNGP11.phx.gbl...
Hi all,

I have been trying to save some user settings when my web application
closes, but with little success. What I want to do is start a counter on
startup, and write the total count to a database when the user logs off,

or
when the user closes the web browser. My problem is that I can't seem to
catch the 'close web browser' event, to write the counter. I've tried to

use
the Session_End handler in global.asax, but that doesn't seem to work.

Any ideas?

Thanks,

Jaco


Nov 18 '05 #3
The way I've approached this in the past, is by using the onunload event,
and a global frameset. The global frameset can consist of one frame, which
contains the website. The frameset has an onUnload event handler attached,
to execute a server-side page when the user navigates away from the site (or
closes the browser). Navigating within the site will happen within the
frame, which won't fire the onUnload event.

E.g.

In the head section, we could have the following script:

<script language="javascript">
function window_onunload()
{
window.open("http://www.domain.com/dosomething.aspx");
}
</script>
Our frameset could consist of the following:

<frameset rows="100%" onUnload="window_onunload()">
<frame name="MainFrame" src="default.aspx" marginwidth="0"
marginheight="0" scrolling="auto" frameborder="0">
</frameset>

It's not quite the same as the browser firing an event when it's closing.
However, the above method can be applied to achieve relatively good results.
But, as a precaution, I agree that it's always best to use the Session_OnEnd
event, as this is the only reliable way to catch the end of a session and
the browser being closed down.

Mun


"Kevin Spencer" <ke***@DIESPAMMERSDIEtakempis.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
Now, Id' surely like to know how the browser is supposed to send a request
when it is closing. The only reliable way to snag the end of the browser
session is with the Session_OnEnd event.

--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
http://www.takempis.com
Big Things are made up of
Lots of Little Things.

Nov 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Andras Gilicz | last post by:
Hi VB fans I'm working on a relatively large project in VB6 with about a dozen forms, including graphs, labels, text boxes, etc. The software itself is actually a flow simulator with more or...
3
by: Stefano | last post by:
I've a form windows with a lot of textbox controls. How can I do if I have to save all text proprety of this controls in an external file, to reload them in future?
0
by: ssg31415926 | last post by:
I've been trying to save a hashtable in an Application Settings file. I need to save settings for each tabPage on a form. Trouble is, the number of tabPages is determined at runtime, so I can't...
1
by: sathyp | last post by:
Public Function SetPrinterDefaultsW(ByVal sPrinterName As String, _ ByVal nPaperSize As Long, ByVal nOrientation As Long) As Boolean Dim Prn As Printer Dim hPrinter As Long Dim pd As...
2
by: John | last post by:
I have a Win app in C#. I want to save the data the user enterere into textboxes and the selections the user made to comboboxes when the user close the app. So next time when the user launches the...
4
by: Richard Lewis Haggard | last post by:
I have an application that can't use the registry to save various user options and application settings. My first thought was to simply use an application configuration file but this approach seems...
2
by: Matuag | last post by:
Hi All, I want to create following command buttons on a Form which users can edit. Save ( Save Changes made) Cancel ( Undo data changes) Exit ( Close form) I am using Macros for each of...
0
by: =?Utf-8?B?Qy4gSHVnaGVz?= | last post by:
Hello, I have a .net 2.0 application using a 'Settings.settings' configuration file to store application settings. The settings are modified at runtime and stored when the user exits the...
3
by: evenlater | last post by:
I have an Access application on a terminal server. Sometimes my users need to export reports to pdf, rtf or xls files and save them to their own client device hard drives. They can do that right...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.