I have a website in an IIS 7 shared hosting environment. It's running .NET 3.5. I have a download button to download a file from the server.
When I locally deploy this application to IIS 6, it runs fine. On the IIS 7 shared hosting server, the exception occurs.
The handle is invalid. (Exception from HRESULT: 0x80070006 (E_HANDLE)) Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
System.Runtime.InteropServices.COMException: The handle is invalid. (Exception from HRESULT: 0x80070006 (E_HANDLE))
COMException (0x80070006): The handle is invalid. (Exception from HRESULT: 0x80070006 (E_HANDLE))] [HttpException (0x80004005): An error occurred while communicating with the remote host. The error code is 0x80070006.]
How can this be solved?
string strRequest = Convert.ToString(Request.QueryString.Get("file"));
System.IO.FileInfo file = new System.IO.FileInfo(strRequest);
if (file.Exists)
{
Response.Clear();
Response.ContentType = ReturnExtension(System.IO.Path.GetExtension(file.Name));
Response.AppendHeader("Content-Disposition", "attachment; filename=" + file.Name);
Response.TransmitFile(strRequest);
Response.End();
HttpContext.Current.ApplicationInstance.CompleteRequest();
//DownloadFile(file.FullName, file.Name);
}
An error occurred while communicating with the remote host. The error code is 0x80070006.
– David Heffernan