设一个Application变量,在Session中进行增减,如超过人数,则拒绝用户登陆。

解决方案 »

  1.   

    如果你能控制IIS,那么在IIS中控制访问人数是较为简单的办法。
    其他的办法我也不清楚,共同学习!
      

  2.   

    楼上所说不太可行,用http方式很难控制的。。如果在IIS中限制,只能做到限制同时连接数。(包括下载文件和浏览页面的请求)我觉的,对于文件传输,最好采用ftp方式,并且现有的ftp软件很容易对带宽、连接数、每个ip连接限制等进行限制的。。集中精力做你的页面,把这些问题留给现有的实现吧。
      

  3.   

    用页面代码和数据库结合实现,,,数据表字段:
    1、下载文件编号
    2、下载文件路径
    3、下载文件名称
        .
        .
        .用户页面设计:
        下载链接,链向文件下载页面,并传递参数,
        如,<a href='<%# String.Format("filedownload.aspx?ID={0}",DataBinder.Eval(Container.DataItem,"下载文件编号"))%>' target="_blank">下载文件名</a>下载页面(filedownload.aspx)设计:
        该页面中,用户页面传递来的参数(下载文件编号)在数据库中对应下载文件的路径,利用application和session对象,来限制下载用户,并同时关闭此页。祝成功!!!
      

  4.   

    用application["DownloadingUsers"]保存正在下载用户的数量,然后用
    Session["EnableDownload"]来控制权限
      

  5.   

    Hi Guys, I don't think ur method is workable. How do u guys know the exact number of users who is downloading the file? 
    How do u know the completion of downloading? 
    What happen if the user cancel downloading and close the browser? The session_end will never fired.Use application and session variable can only knows the total number of downloads, but not the number of concurrent downloading users in real time.
    Pls refer to my another post at http://expert.csdn.net/Expert/topic/2269/2269253.xml?temp=.1252558In that thread, I use my method for a secure download, but I think it is simple to modify my code in order to serve your purpose.
      

  6.   

    在下载页面的page_load中
    application["DownloadingUsers"]加1
    当application["DownloadingUsers"]=10时,拒绝该页面
      

  7.   

    To gj0001(阿江),Page_Load does not means a real downloading started. My another question is how do u know the completion of downloading? When to "-1" from application["DownloadingUsers"]?
      

  8.   

    To laochen(天行者):
      you are right!