我有大文件(大约 2GB)要分发给我们的客户,我的网站是由 asp.net vb 编写的,这是我的文件下载处理程序:
Public Class FileHandler
Implements IHttpHandler
Public Sub ProcessRequest(ByVal httpcontext As HttpContext) Implements IHttpHandler.ProcessRequest
If HttpContext.User.Identity.IsAuthenticated Then
Dim FileName As String = HttpContext.Request.QueryString("File")
HttpContext.Response.Buffer = False
HttpContext.Response.Clear()
HttpContext.Response.AddHeader("content-disposition", "attachment; filename=" & FileName)
HttpContext.Response.ContentType = "application/exe"
HttpContext.Response.TransmitFile("~/download/ExE/" & FileName)
HttpContext.Response.Flush()
HttpContext.Response.Close()
End If
End Sub
Public ReadOnly Property IsReusable As Boolean Implements IHttpHandler.IsReusable
Get
Return False
End Get
End Property
End Class
我的问题是这个处理程序有时无法正常工作。大部分客户都可以通过这个handler下载,但是有些客户点击下载链接,会无休止地等待服务器的响应,等待很长时间后,显示错误页面,说IE无法显示网页。有些客户尝试从 IE8 下载文件,它会直接显示错误页面。我非常感谢任何人可以帮助解决这个问题。谢谢!