Answers for "C# MemoryStream - Timeouts are not supported on this stream"

C#
0

C# MemoryStream - Timeouts are not supported on this stream

[System.Web.Http.HttpGet]
    [System.Web.Http.Route("export-to-csv")]
    public FileStreamResult ExportDeposits([FromUri(Name = "")]DepositSearchParamsVM depositSearchParamsVM)
    {
        if (depositSearchParamsVM == null)
        {
            depositSearchParamsVM = new DepositSearchParamsVM();
        }
        var records = _DepositsService.SearchDeposits(depositSearchParamsVM);
        var result = _DepositsService.WriteCsvToMemory(records);
        var memoryStream = new MemoryStream(result);
        Response.ContentType = new MediaTypeHeaderValue("application/octet-stream").ToString();// Content type
        return new FileStreamResult(memoryStream, "text/csv") { FileDownloadName = "export.csv" };
    }
Posted by: Guest on July-13-2021

Code answers related to "C# MemoryStream - Timeouts are not supported on this stream"

C# Answers by Framework

Browse Popular Code Answers by Language