I have been using the below code and it fails when rows are more than 70K.
I tried to put breakpoint on button click but it breaks right after i hit the button.
Here's the complete error:
HTTP Error 404.13 - Not Found
The request filtering module is configured to deny a request that exceeds the request content length.
Most likely causes: Request filtering module is configured on the Web Server to deny the request because the content length exceeds the configured value.
public void btnToCSV_Click(object sender, EventArgs e)
{
Response.Clear();
Response.Buffer = true;
Response.AddHeader("content-disposition", "attachment;filename=Report.csv");
Response.Charset = "";
Response.ContentType = "application/text";
StringBuilder sBuilder = new System.Text.StringBuilder();
for (int index = 0; index < gvReport.Columns.Count; index++)
{
sBuilder.Append(gvReport.Columns[index].HeaderText + ',');
}
sBuilder.Append("\r\n");
for (int i = 0; i < gvReport.Rows.Count; i++)
{
for (int k = 0; k < gvReport.HeaderRow.Cells.Count; k++)
{
if (gvReport.Rows[i].Cells[k].Text.Length == 0 || gvReport.Rows[i].Cells[k].Text.Equals(" ") || gvReport.Rows[i].Cells[1].Text.Equals("") || gvReport.Rows[i].Cells[1].Text.Equals(string.Empty))
{
sBuilder.Append(gvReport.Rows[i].Cells[k].Text = string.Empty + ',');
}
else
{
sBuilder.Append(gvReport.Rows[i].Cells[k].Text.Replace(",", "") + ",");
}
}
sBuilder.Append("\r\n");
}
Response.Output.Write(sBuilder.ToString());
if (Response.IsClientConnected)
{
Response.Flush();
Response.End();
}
}
I have tried using
<httpRuntime executionTimeout="240" maxRequestLength="102400" />
But it still doesn't help me you. I pressed F12 and then click on the export button and under "Network" tab it showed me status 404 in Red. Please help me out.
Thanks,
Abhishek