首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Response.TransmitFile的问题

Response.TransmitFile的问题
EN

Stack Overflow用户
提问于 2012-09-27 09:13:54
回答 1查看 1.1K关注 0票数 0

在过去的两天里,我一直在研究一个问题,我尝试了所有可能的调试方法,但都是徒劳的。在生产环境中,我的local.But上一切正常,但失败了。以下是对该问题的简要描述。我有一个下载按钮,当我点击这个按钮时,我打算从服务器上下载一个文件。

受保护的无效发送者(object Download_Click,EventArgs e) {

代码语言:javascript
复制
    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 failed:FileName:dsdfsfd.doc,模拟启用:0,Token Valid:1 HRESULT:0x8007052e。

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

如有任何帮助和意见,我们将不胜感激。谢谢。

EN

回答 1

Stack Overflow用户

发布于 2012-09-27 23:14:34

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

代码语言:javascript
复制
Error code: (HRESULT) 0x8007052e (2147943726) - Logon failure: unknown user name or bad password.

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

代码语言:javascript
复制
cdb notepad.exe

然后在启动后:

代码语言:javascript
复制
0:000> !error  0x8007052e
Error code: (HRESULT) 0x8007052e (2147943726) - Logon failure: unknown user name or bad password.

希望它能有所帮助:)

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/12612701

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档