473,788 Members | 2,759 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.redire ct("./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 1452
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******@comca st.net> wrote in message
news:uN******** ******@TK2MSFTN GP10.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.redire ct("./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******@comca st.net> wrote in message
news:uN******** ******@TK2MSFTN GP10.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.redire ct("./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******@comca st.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.redir ect("./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.WriteF ile. 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******@comca st.net> a écrit dans le message de
news:uN******** ******@TK2MSFTN GP10.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.redire ct("./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******@comca st.net> confessed in news:uNzc2J8AFH A.1296
@TK2MSFTNGP10.p hx.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.redire ct("./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
2104
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 ASP? Thanks in advance, G.
5
3657
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 these menus are then placed into the page by calling Server.Execute(rs_Modules("ModulePath")). This works fine for up to 15 "menus" After that, the session variables that were set (not including those called by Global.ASA) are no longer set. ...
5
14722
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 some other open files and then shutting down gracefully. I've done a lot of searching online and there seem to be a lot of potentially interesting leads, an OnShutdown is mentioned, as is a SessionEnding event, but I'm not sure what the normal...
2
2322
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, and I'm baffled. I've done some more Google searches and have come up with the same thing. A portion of the code is below. I call the HookSessionEnding routine in the Load event of the main form, but the shutdown event code never fires. I'm baffled....
2
2423
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 information in a class and then dump it into a session variable. The timeout on the server is set to 2hrs. Every now and then (5min-30min) the web server will lose the session variable. This is very inconsistent and doesn't appear to have an associated...
6
2388
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 sessions (average) the memory rises about 300 MB's in an hour. I've checked the database (SQL Server 2000) and seen that there are lots of sleeping connections. (about 400!!!) I thought somewhere in the code they left the connection open, so decided...
0
1295
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 be called from within Session_End? I can think of some "tricks" (adding a "closing" item to the session just before doing a Session.Abandon(), for example) but is there a clean way to do it?
4
2764
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 lost and show an explanatory message before restarting the session. Rather than tagging a 'session in progress' flag on the end of every request querystring I'd like to detect it using data sent in every request. One idea I had was that when...
2
2678
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 session that is running at the closed browser. Is it possible to resume a session like that? Any sample code provided?
0
9656
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9498
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10373
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10118
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
6750
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5538
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4074
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3677
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2897
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.