Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   ASP .Net (http://www.velocityreviews.com/forums/f29-asp-net.html)
-   -   Save settings on exit (http://www.velocityreviews.com/forums/t66859-save-settings-on-exit.html)

Jaco Bregman 11-17-2003 10:45 AM

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



Munsifali Rashid 11-17-2003 12:37 PM

Re: Save settings on exit
 
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" <someone@microsoft.com> wrote in message
news:O7yrfgPrDHA.3688@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
>
>




Kevin Spencer 11-17-2003 01:43 PM

Re: Save settings on exit
 
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:OFZw7eQrDHA.2692@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" <someone@microsoft.com> wrote in message
> news:O7yrfgPrDHA.3688@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
> >
> >

>
>




Munsifali Rashid 11-18-2003 12:26 AM

Re: Save settings on exit
 
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" <kevin@DIESPAMMERSDIEtakempis.com> wrote in message
news:%23uBR6ERrDHA.1496@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.





All times are GMT. The time now is 07:26 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.