public ActionResult ExportLog(string guid) { UpdateTaskInquiryProvider updateTaskInquiryProvider = new UpdateTaskInquiryProvider(); MemoryStream memoryStream = new MemoryStream(); TextWriter tw = new StreamWriter(memoryStream); var data = updateTaskInquiryProvider.getLog(guid); foreach (var item in data) { tw.WriteLine("TASK ID : " + item.TASK_ID + ", UPLOAD_MESSAGE : " + item.UPLOAD_MESSAGE); } tw.Flush(); tw.Close(); return(File(memoryStream.GetBuffer(), "text/plain", "Dukcapil_Log_datagagalupload_" + DateTime.Now.ToString("yyyyMMdd") + ".txt")); }