2012-12-17 103 views
0

我們有這個網站,我們也有簽證申請模塊。簽證申請模塊要求用戶創建一個帳戶。每當用戶上傳附件時,它都會保存在附件中的特定文件夾中。該特定文件夾對應於分配給每個用戶的唯一生成的數字。限制直接訪問我們的附件文件夾

現在我需要的是如果用戶沒有登錄他們不應該能夠訪問附件文件夾內的文件。

我該如何實現使用http處理程序?

我有這樣的代碼

if (HttpContext.Current.Session["UserRegistrationID"] != null) 
      { 
       if (HttpContext.Current.Session["UserRegistrationID"].ToString() != "") 
       { 
        DownloadFile(context); 
       } 
       else 
       { 
        context.Response.Write("You don't have the rights to access this file."); 
        context.Response.Flush(); 
       } 
      } 
      else 
      { 
       context.Response.Write("You don't have the rights to access this file."); 
       context.Response.Flush(); 
      } 

protected void DownloadFile(HttpContext context) 
     { 

     context.Response.ContentType = "image/jpg"; 
     context.Response.WriteFile(context.Request.PhysicalPath); 
     context.Response.Flush(); 
    } 

但問題是我有在網絡配置配置方面的問題。

有誰知道如何做到這一點?

回答