I have been working on an issue for the past 2 days.I have tried to debug in every way possible but in vain. Everything works fine on my local.But on production this fails. Here is a brief description about the problem. I have a download button and when I click that button I intend to download a file from a server.
protected void Download_Click(object sender, EventArgs 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();
}
I see on the Event Viewer that it generates: TransmitFile failed:FileName:dsdfsfd.doc,Impersonation Enabled:0,Token Valid:1 HRESULT:0x8007052e.
Environment: The website is deployed on a Windows 2000 server.
Any help and comments would be appreciated. Thank you.
The account under which your application is running (probably IIS pool account) does not have access to the file that you are trying to send. The error code 0x8007052e
means:
Error code: (HRESULT) 0x8007052e (2147943726) - Logon failure: unknown user name or bad password.
In the future you can check the error code using for instance cdb command (cdb is a part of the freely available Windows Debugging Tools):
cdb notepad.exe
And then after it has started:
0:000> !error 0x8007052e
Error code: (HRESULT) 0x8007052e (2147943726) - Logon failure: unknown user name or bad password.
Hope it helps :)
User contributions licensed under CC BY-SA 3.0