473,405 Members | 2,300 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,405 software developers and data experts.

detecting the session closing

Hi all,
I have a web page(a) that has a link to another web page(b). Now, on the
page load event of web page(b), I am doing the following:

Response.redirect("./test.pdf")

This pdf, if the user copies the url, can go back to it after they have
logged out of my web site.
I need to delete this file. I need to find a way to detect the web page is
closing so I can delete the pdf file.
Of course, redirecting to the pdf opens the pdf in its own page, so I can't
code to delete the file that way.

How can I detect that the user has close the pdf file?

Any help is greatly appreciated, as I need to resolve this ASAP.
Thanks

Russell
Nov 19 '05 #1
5 1429
Why not handle the session_end event, and in that event delete the file.

Closing the browser is not in any way related to sessions ending, btw. This
even will fire after the idle timeout is reached.

"Russell" <la******@comcast.net> wrote in message
news:uN**************@TK2MSFTNGP10.phx.gbl...
Hi all,
I have a web page(a) that has a link to another web page(b). Now, on the
page load event of web page(b), I am doing the following:

Response.redirect("./test.pdf")

This pdf, if the user copies the url, can go back to it after they have
logged out of my web site.
I need to delete this file. I need to find a way to detect the web page is
closing so I can delete the pdf file.
Of course, redirecting to the pdf opens the pdf in its own page, so I
can't
code to delete the file that way.

How can I detect that the user has close the pdf file?

Any help is greatly appreciated, as I need to resolve this ASAP.
Thanks

Russell

Nov 19 '05 #2
Russell, sounds like you're trying to construct a simple, secure document
management system.

I don't have a particularly satisfying solution for the
delete-when-user-leaves approach. It's difficult to detect a users
departure accurately, which hampers this approach greatly.

If you want to pursue that, the best solution I can recommend is to have a
"heartbeat" between the client and the server. Each tick of the heartbeat
would update a "last seen" timestamp on a database table that identifies the
document. On a request for the document (which, I'm guessing, is a special
copy intended for that one user only), you compare DateTime.Now to the
timestamp the heartbeat was last seen. If it's too long, you just deny the
request and delete the document.

The heartbeat is simple enough to construct; have a hidden frame or a 1x1
IFRAME in your document display page, and the page loaded in the IFRAME can
use the auto-refresh tag at a 30 second interval. Crude, but amazingly it
works, and if the user closes their browser you can safely do cleanup in as
little as 65 seconds or so (I use 2 beats for safety).

This approach also avoids having a back-end process, but suffers from a
trash problem. If a user views their document, and dutifully closes their
browser and never requests it again, there is no further event specific to
that document. You never get to take out the trash. A back-end process
that runs every 5 mins, checks the db table for old files and deletes them
is easy to construct if you want to keep your "document cache" clean.

If I've interpreted your objectives correctly so far, let me suggest a
completely different solution;

Eliminate the cache. Store the documents somewhere else, e.g. on your
network or in the database. When a user requests a document, have them
request it from an .aspx page that goes and retrieves the document and
writes it back to the user.

This approach is much cleaner, and ultimately simpler. No temp documents,
no files to copy or delete.

/// M
"Russell" <la******@comcast.net> wrote in message
news:uN**************@TK2MSFTNGP10.phx.gbl...
Hi all,
I have a web page(a) that has a link to another web page(b). Now, on the
page load event of web page(b), I am doing the following:

Response.redirect("./test.pdf")

This pdf, if the user copies the url, can go back to it after they have
logged out of my web site.
I need to delete this file. I need to find a way to detect the web page is
closing so I can delete the pdf file.
Of course, redirecting to the pdf opens the pdf in its own page, so I can't code to delete the file that way.

How can I detect that the user has close the pdf file?

Any help is greatly appreciated, as I need to resolve this ASAP.
Thanks

Russell

Nov 19 '05 #3
On Wed, 26 Jan 2005 10:16:27 -0600, "Russell" <la******@comcast.net>
wrote:
Hi all,
I have a web page(a) that has a link to another web page(b). Now, on the
page load event of web page(b), I am doing the following:

Response.redirect("./test.pdf")

This pdf, if the user copies the url, can go back to it after they have
logged out of my web site.
I need to delete this file. I need to find a way to detect the web page is
closing so I can delete the pdf file.
Of course, redirecting to the pdf opens the pdf in its own page, so I can't
code to delete the file that way.

How can I detect that the user has close the pdf file?

Any help is greatly appreciated, as I need to resolve this ASAP.
Thanks

Russell

Why not use the session end event in global.asax?

Or if you are not using sessions and want to force someone to be
logged into view the file then store it off the website and process
the request for the file by checking they are logged in and then
pushing the binary back to their browser.

I

--
Iain Norman | http://www.eliteforum.org
Nov 19 '05 #4
Not sure what the exact problem is but instead you could perhaps stream the
PDF file to the browser using Response.WriteFile. It allows to store the PDF
file outisde of the web site and you can perform addtional checks before
allowing the download...

That said I don't really see what you try to avoid. Once they have the PDF
they can do whatever wiht it without even having to return to this URL
(unless this is a temporary file or whatever else created on the fly each
time in which case using the same name for all users could be perhaps
problematic ???)

Or do you copy the file here and you would like to remove it once the
download is over ? (in hwihc case the streaming solutuion could help).

Patrice

--

"Russell" <la******@comcast.net> a écrit dans le message de
news:uN**************@TK2MSFTNGP10.phx.gbl...
Hi all,
I have a web page(a) that has a link to another web page(b). Now, on the
page load event of web page(b), I am doing the following:

Response.redirect("./test.pdf")

This pdf, if the user copies the url, can go back to it after they have
logged out of my web site.
I need to delete this file. I need to find a way to detect the web page is
closing so I can delete the pdf file.
Of course, redirecting to the pdf opens the pdf in its own page, so I can't code to delete the file that way.

How can I detect that the user has close the pdf file?

Any help is greatly appreciated, as I need to resolve this ASAP.
Thanks

Russell

Nov 19 '05 #5
"Russell" <la******@comcast.net> confessed in news:uNzc2J8AFHA.1296
@TK2MSFTNGP10.phx.gbl:
Hi all,
I have a web page(a) that has a link to another web page(b). Now, on the
page load event of web page(b), I am doing the following:

Response.redirect("./test.pdf")

This pdf, if the user copies the url, can go back to it after they have
logged out of my web site.
I need to delete this file. I need to find a way to detect the web page is
closing so I can delete the pdf file.
Of course, redirecting to the pdf opens the pdf in its own page, so I can't
code to delete the file that way.

How can I detect that the user has close the pdf file?

Any help is greatly appreciated, as I need to resolve this ASAP.
Thanks

Russell


Russell,

You can't easily tell when a user closes a PDF file, as opening the pdf is
really invoking another application on the client, the Acroread32 process.

You *can* add a session close method in global.asax as OPs have suggested,
but this is not guaranteed to work, as closing the session is generally
dependent on the server timeout, not an action explicitly performed by the
webapp.

If, and only if, you can make your users logout and explicitly close their
session, then you can make deleting this file as part of the process.

But how do you do this?

-- ipgrunt
Nov 19 '05 #6

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

Similar topics

2
by: G | last post by:
Hello, I want to launch a pop-under survey when a user leaves my page by closing the window, but NOT by leaving the page via a hyperlink or form submission. Is this easy to accomplish with...
5
by: Phil Grimpo | last post by:
I have a very odd situation here. I have an administration page, where based on a users permissions, a recordset is called from the SQL server which has a list of paths to "Module Menus". Each of...
5
by: David Griffin | last post by:
I have a console application that spawns off several C# threads. It needs to react to shutdown of the system by performing some end of program activities including writing some files and closing...
2
by: Paul Steele | last post by:
Some time ago I tracked down the code for detecting the shutdown event within a C# program. I tested it, it worked, and I moved on. However, I just discovered that the code is no longer working,...
2
by: Nate Spillson | last post by:
I have an asp.net web application that uses session variables to store user information (username, security areas, configuration data). When the user logs into the system I store all of this...
6
by: Gonenc Ercan | last post by:
Hi, I ve ended up debugging a ASP.NET project (with about 380 files on the project .NET Framework 1.0 on IIS 5.0) which has a memory leak... The memory rises too fast. With about 25-30 active...
0
by: jules | last post by:
Session_End (global.aspx) is called when Session.Abandon() gets called explicitly, or when the Session times out (20 minutes by default). Is there a way to tell which event caused Session_End to...
4
by: Chris | last post by:
When a request comes into a page on my ASP.net site and a session is not found, I want to detect whether the request is an initial request or if the user did have a session going that has now been...
2
by: RC | last post by:
hi, I now got a session ID. I want to try to resume a session by closing the current browser and open a new one. Then pass the session ID in URL query string on new browser to resume the...
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: 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
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,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.