2012-09-27 26 views
0

我一直在處理過去2天的問題。我試圖以各種方式進行調試,但徒勞無功。 一切工作正常我的local.But生產失敗。 以下是有關該問題的簡要說明。 我有一個下載按鈕,當我點擊那個按鈕時,我打算從服務器下載一個文件。問題與Response.TransmitFile

保護無效Download_Click(對象發件人,EventArgs的) {

Button downloadButton = sender as Button; 
    string filePath = downloadButton.CommandArgument;  

    string stuid = Session["browse_files_for_student"].ToString(); 
    string stuUsername = MyHelper.GetUsernameForStudentID(stuid); 
    MyHelper.LogAccess(User.Identity.Name, StudentUsername.Text, filePath, MyHelper.LogAccessType.Read); 
    FileInfo file = new FileInfo(filePath); 

    // Download the file 
    Response.Clear(); 
    Response.AppendHeader("content-disposition", "attachment; filename=" + file.Name); 
    try 
    { 
     Response.TransmitFile(filePath);   
    } 
    catch (IOException error) 
    { 
     Response.Cookies.Add(new HttpCookie("global_last_error", "The file is in use by another process.")); 
     Response.Redirect("~/Public/KnownError.aspx"); 
    } 
    Response.End(); 

} 

我在事件查看器看到,它產生: 的TransmitFile失敗:文件名:dsdfsfd.doc,模擬啓用:0,令牌有效:1 HRESULT:0x8007052e。

環境:網站部署在Windows 2000服務器上。

任何幫助和意見,將不勝感激。 謝謝。

回答

0

您的應用程序正在運行的帳戶(可能是IIS池帳戶)無權訪問您嘗試發送的文件。錯誤代碼0x8007052e表示:

cdb notepad.exe 

然後:

Error code: (HRESULT) 0x8007052e (2147943726) - Logon failure: unknown user name or bad password. 

在未來你可以使用例如CDB命令(CDB是免費提供的Windows調試工具的一部分)來檢查錯誤代碼它啓動後:

0:000> !error 0x8007052e 
Error code: (HRESULT) 0x8007052e (2147943726) - Logon failure: unknown user name or bad password. 

希望它能幫助:)