当用户留下请求时,我可以控制清洁项目吗?

发布于 2024-07-27 20:00:23 字数 192 浏览 6 评论 0原文

我有一个允许上传多个文件的页面,文件不断上传,即有许多 FileUpload 控件和每个文件附近的提交按钮,并且它会立即上传。

我希望,一旦用户离开页面并转到另一个页面而不保存主容器(例如“项目”=产品/注释/文档/这些文件附加到的任何内容),上传的文件应该从服务器中删除。

换句话说:我怎么知道用户不打算回来(即他关闭浏览器等)

I have a page that allows uploading of multiple files, the files are uploaded constantly, i.e. there are many FileUpload controls and a submit button near each of them and it uploads immediately.

I want, that once the user leaves the page and goes to another page without saving the main container (e.g. the 'item' = a product/note/doc/whatever these files are attached to), the uploaded files should be deleted from server.

In other words: how can I know that the user is not intend to come back (i.e. he shuts down his browser etc.)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

千と千尋 2024-08-03 20:00:23

简而言之,您无法准确知道用户何时决定离开您的网站,除非她专门单击“注销”并被重定向到其他地方。

最好的选择是在 Global.asax 中的 Session_End() 事件处理程序期间在用户之后进行清理。

The short answer is that you can't know precisely when the user decides to leave your site, unless she specifically clicks "logout" and is redirected somewhere else.

Your best bet would be to clean up after the user during the Session_End() event handler in Global.asax.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文