怎样才能让没有登录的用户不能下载?
如果有一些文件放在如:
http://localhost/download/讲座1.rar
http://localhost/download/讲座2.rar
http://localhost/download/讲座....rar用户已经知道详细路径,在不登录的情况下直接输入地址就可以下载,如果让用户必须
登录后才能下载,并有用户下载记录写到数据库里,应该怎么做,非常感谢!

解决方案 »

  1.   

    你加个登入判断好了,
    if(登入条件)
    {
    down
    }
    else
    {
    not down
    }
      

  2.   

    用户知道文件地址的话,登不登录都没有用了,还判断有啥用?====CSDN 小助手 V2.5 2005年11月05日发布====
    CSDN小助手是一款脱离浏览器也可以访问Csdn论坛的软件
    界面:http://blog.csdn.net/Qqwwee_Com/archive/2005/11/05/523395.aspx
    下载:http://szlawbook.com/csdnv2
      

  3.   

    试过了,不行!只对.ASPX文件启作用,其他文件不管用
      

  4.   

    用httpHandler技术
    ms-help://MS.MSDNQTR.2003FEB.2052/cpguide/html/cpconhttphandlers.htm
    ms-help://MS.MSDNQTR.2003FEB.2052/cpgenref/html/gngrfhttphandlerssection.htm
      

  5.   

    先用Session记录信息,然后判断有没有登陆,没有就转向登陆页面,登陆则转向文件url
      

  6.   

    怎么就没人明白我的意思呢,还是我没说明白。
    用Session根本不行
    如果已经知道下载地址了,判断和登录是无用的。
      

  7.   

    Session在httphandler里可以用你的IHttpHandler实现类里,同时必须实现IRequiresSessionState
      

  8.   

    然后在 ProcessRequest(
       HttpContext context
    )
    {
       object o = context.Session[""];
    }
      

  9.   

    判断cookie,如果登陆转向下载地址的连接,否则错误提示
      

  10.   

    使用Windows的域用户管理,对下载目录设置权限,所有注册的用户在Windows的域用户里面增加权限。
      

  11.   

    download.aspx  Protected Overloads Overrides Sub Render(ByVal writer As HtmlTextWriter)
    '在这里写代码判定用户是否登陆
    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
      

  12.   

    对download文件夹控制禁止直接访问。以前看到过,不知行不行。