怎样才能让没有登录的用户不能下载?
如果有一些文件放在如:
http://localhost/download/讲座1.rar
http://localhost/download/讲座2.rar
http://localhost/download/讲座....rar用户已经知道详细路径,在不登录的情况下直接输入地址就可以下载,如果让用户必须
登录后才能下载,并有用户下载记录写到数据库里,应该怎么做,非常感谢!
如果有一些文件放在如:
http://localhost/download/讲座1.rar
http://localhost/download/讲座2.rar
http://localhost/download/讲座....rar用户已经知道详细路径,在不登录的情况下直接输入地址就可以下载,如果让用户必须
登录后才能下载,并有用户下载记录写到数据库里,应该怎么做,非常感谢!
if(登入条件)
{
down
}
else
{
not down
}
CSDN小助手是一款脱离浏览器也可以访问Csdn论坛的软件
界面:http://blog.csdn.net/Qqwwee_Com/archive/2005/11/05/523395.aspx
下载:http://szlawbook.com/csdnv2
ms-help://MS.MSDNQTR.2003FEB.2052/cpguide/html/cpconhttphandlers.htm
ms-help://MS.MSDNQTR.2003FEB.2052/cpgenref/html/gngrfhttphandlerssection.htm
用Session根本不行
如果已经知道下载地址了,判断和登录是无用的。
HttpContext context
)
{
object o = context.Session[""];
}
'在这里写代码判定用户是否登陆
if (没有登陆) then
return
end if
Dim file As System.IO.FileInfo = New FileInfo(服务器上文件绝对地址)
System.Web.HttpContext.Current.Response.Clear()
System.Web.HttpContext.Current.Response.ContentType = attachment.ContentType
Dim fInfo() As String = attachment.DownFile.Split("/")
Dim filename As String = ""
If fInfo.Length >= 2 Then
filename = fInfo(1)
Else
filename = "在下载的文件名称"
End If
System.Web.HttpContext.Current.Response.AppendHeader("content-disposition", "attachment; filename=""" + filename + """")
System.Web.HttpContext.Current.Response.AddHeader("Content-Length", file.Length.ToString())
System.Web.HttpContext.Current.Response.WriteFile(file.FullName)
System.Web.HttpContext.Current.Response.End()
end sub