Export large amounts of data to a client in asp.net

I need to export a large amount of data (~ 100 MB) from a sql table to a user through a network. What would be the best solution for this? One thought was to export the data to a folder on the db server, compress it (somehow), and then provide a download link for the user. Any other methods for this? Also, can we compress data from sql server?

Any approaches are welcome.

+5
source share
5 answers

I would not anchor the database, expecting the user to download 100 MB, even for a high-speed user. When the user requests a file, provide an email address. Then call the asynchronous process to extract the data, write it to the temp file (no need> 100 MB in memory after all), then pin the temp file to the storage, and then send the user an email with a link to download the file.

+4
source

You can answer the page request with the file:

Response.AddHeader("Content-Disposition", 
    "attachment; filename=yourfile.csv");
Response.ContentType = "text/plain";

Be sure to disable buffering, so IIS may start sending the first part of the file when creating the second:

Response.BufferOutput = false;

After that, you can start recording the file, for example:

Response.Write("field1,field2,field3\r\n");

When the file is completely written, complete the answer, so ASP.NET does not add the web page to your file:

Response.End();

, -, .

, ZIP . ZIP .

+3

- . , . .

SQL Server. DotNetZip ( System.IO.Conpression, , gzip) -.

0

. SSIS + 7zip , .

0

All Articles