响应传输文件的问题



在过去的两天里,我一直在处理一个问题。我试图以各种可能的方式进行调试,但徒劳无功。在我的本地一切正常。但是在生产中,这失败了。以下是有关该问题的简要说明。我有一个下载按钮,当我单击该按钮时,我打算从服务器下载文件。

受保护的无效Download_Click(对象发送方,事件参数 e) {

    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();
}

我在事件查看器上看到它生成:传输文件失败:文件名:dsdfsfd.doc,启用模拟:0,令牌有效:1 结果:0x8007052e。

环境:网站部署在 Windows 2000 服务器上。

任何帮助和意见将不胜感激。谢谢。

运行应用程序的帐户(可能是 IIS 池帐户)无权访问您尝试发送的文件。错误代码0x8007052e表示:

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

将来,您可以使用例如cdb命令检查错误代码(cdb是免费提供的Windows调试工具的一部分):

cdb notepad.exe

然后在它开始之后:

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

希望对:)有所帮助

最新更新