Web Browser Close Event

  • Thread starter Thread starter MikeZ
  • Start date Start date
M

MikeZ

I know this is an ASP.NET question, but I know some experts can help me in
this newsgroup:

I have an asp.net web page, I need to push indefinite live video stream to
web Brower, and here is the code:

''''''''''''''''''''''''''''''''''''''''''''''
protected void Page_Load(object sender, EventArgs e)
{
while (true)
{
tmpArray = GetMethod();
Response.BinaryWrite(tmpArray);
Response.BinaryWrite(MJPGHeader);
Response.Flush();
}
}
''''''''''''''''''''''''''''''''''''''''''''''''

It works fine. But when the WebBrowser closed, APS.NET still loops inside of
the Page_Load Event, and never come out.

My question is: How can I exit Page_Load subroutine after client web browser
closed. It is strange that No exception throwed in Response.BinaryWrite()
when client closed.

Thanks
 
My question is: How can I exit Page_Load subroutine after client web
browser
closed. It is strange that No exception throwed in Response.BinaryWrite()
when client closed.

You can't do that without some javascript code, because OnUnload is a
client-side event.

However you can validate this using the session state or a client-side
cookie during the loop and skip the process.
 
David, I don't think client side Javascripts can do anything on server side
loop. I will test the Session_End event in Global.asax file.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top