检测用户是否下载了文件
我想检测用户是否单击了下载或查看超链接。这是一个人们可以上传文件的页面,如果需要,他们也可以查看文件(任何人上传的文件)。我正在使用 asp.NET 上传文件并将其存储在 sql server 数据库中。这些文件然后使用数据库显示在网页上,任何登录的人都可以看到。网页上有多个文件,并且所有文件都有查看或下载链接(像 zip 文件这样的文件没有查看权限)。我想创建一个功能,允许上传文件的用户查看谁看到了他/她的文件。类似文件名的表列以及观看该文件的每个人都被添加到数据库中的列中。 这是我在 gridview 中使用的:
<asp:HyperLinkField DataNavigateUrlFields="Id" DataNavigateUrlFormatString="~/DownloadFile.aspx?Id={0}" HeaderText="Download" Text="Download" />
I want to detect if the user has clicked on the download or the view hyperlinks. It's a page where people can upload files and if needed they can look at files too(files uploaded by anyone). I am uploading the files using asp.NET and storing it in the sql server database. These files are then displayed on the webpage using the database and can be seen by anyone who logs in. There are multiple files on the webpage and all have view or download links(files like zip files don't have view). I want to create a functionality that allows the user who uploaded the files to see who saw his/her file. Something like a table column for the file name and everyone watching the file getting added to the column in the database.
This is what I am using in the gridview:
<asp:HyperLinkField DataNavigateUrlFields="Id" DataNavigateUrlFormatString="~/DownloadFile.aspx?Id={0}" HeaderText="Download" Text="Download" />
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您只需将下载/查看/链接/任何内容转到服务器端组件,该组件在提供文件之前将点击记录在数据库中。
You just need to have your download/view/links/whatever go to a server-side component which records the click in a database before serving the file.
在 HTML 部分中,将其用作按钮代码:
并在脚本部分中添加此函数
in the HTML part use this for the button code:
and on the script part add this function