【发布时间】:2011-10-12 11:43:47
【问题描述】:
我在 IIS 7 共享主机环境中有一个网站。它正在运行 .NET 3.5。我有一个下载按钮,可以从服务器下载文件。
当我将此应用程序本地部署到 IIS 6 时,它运行良好。在 IIS 7 共享主机服务器上,发生异常。
句柄无效。 (来自 HRESULT 的异常:0x80070006 (E_HANDLE)) 说明:执行当前 Web 请求期间发生未处理的异常。请查看堆栈跟踪以获取有关错误及其源自代码的位置的更多信息。
System.Runtime.InteropServices.COMException:句柄无效。 (来自 HRESULT 的异常:0x80070006 (E_HANDLE))
COMException (0x80070006):句柄无效。 (来自 HRESULT 的异常:0x80070006 (E_HANDLE))] [HttpException (0x80004005):与远程主机通信时出错。错误代码为0x80070006。]
如何解决?
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. -
我猜这是因为您的共享主机的权限问题。
-
请告诉我应该授予什么权限?
标签: c# asp.net iis-7 shared-hosting httpexception