无法将大表流式传输到浏览器

时间:2015-09-29 18:26:01

标签: c# asp.net

我在winhost.com上有一个带有支持SQL Server数据库的ASP.NET webforms应用程序。我可以成功下载所有表,除了最大的表(193mb)。我没有运气就搜索并搜索了我被阻挡的内容。

我尝试在web.config中最大化maxRequest和ContentLength但没有成功。 <httpRuntime targetFramework="4.5" maxRequestLength="1048576" executionTimeout="36000" /> <requestFiltering> <requestLimits maxAllowedContentLength="1073741824" /> </requestFiltering>

我的流式伪码如下:

Write the whole table to stringBuilder object

Convert that to byte Array

Stream to Browser

public void StreamFileToBrowser(string sFileName, byte[] fileBytes)
    {
        System.Web.HttpContext context = System.Web.HttpContext.Current;
        context.Response.Clear();
        context.Response.ClearHeaders();
        context.Response.ClearContent();
        context.Response.AppendHeader("content-length", fileBytes.Length.ToString());
        context.Response.ContentType = GetMimeTypeByFileName(sFileName);
        context.Response.AppendHeader("content-disposition", "attachment; filename=" + sFileName);
        context.Response.BinaryWrite(fileBytes);

        // use this instead of response.end to avoid thread aborted exception (known issue):
        // http://support.microsoft.com/kb/312629/EN-US
        context.ApplicationInstance.CompleteRequest();
    }

0 个答案:

没有答案