Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-core/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# Asp.Net Core 3.1从新MS Edge上的控制器返回的文件需要很长时间才能下载_C#_Asp.net Core - Fatal编程技术网

C# Asp.Net Core 3.1从新MS Edge上的控制器返回的文件需要很长时间才能下载

C# Asp.Net Core 3.1从新MS Edge上的控制器返回的文件需要很长时间才能下载,c#,asp.net-core,C#,Asp.net Core,这只是一个从数据库下载excel数据的处理程序,我甚至尝试使用调试器,一切都很顺利。在chrome或firefox上,只要我点击按钮,它的文件就会显示在下载中,但在新的MS Edge上,它需要10到20秒或更长的时间才能开始下载?为什么 public async Task<FileResult> OnGetDownloadExcel(int id) { var inventarios = await _context.Localizations

这只是一个从数据库下载excel数据的处理程序,我甚至尝试使用调试器,一切都很顺利。在chrome或firefox上,只要我点击按钮,它的文件就会显示在下载中,但在新的MS Edge上,它需要10到20秒或更长的时间才能开始下载?为什么

public async Task<FileResult> OnGetDownloadExcel(int id)
    {
        var inventarios = await _context.Localizations
                .Where(l => l.InventoryRecordId == id)
               .Select(ir => new
               {
                   ir.InventoryRecord.Id,
                   Armazem = ir.InventoryRecord.Warehouse.Name,
                   Colaborador = ir.InventoryRecord.User.Name,
                   ir.InventoryRecord.CreationDate,
                   ir.InventoryRecord.ClosedDate,
                   ir.InventoryRecord.Warehouse.Objective,
                   Resultado = (ir.InventoryRecord.Localizations.Sum(l => l.Precision) / ir.InventoryRecord.Localizations.Count()) * 100,
                   Localizacao = ir.Name,
                   ir.LabelsMissing,
                   ir.LabelsStored,
                   ir.Precision,
                   ir.Labels
               })
               .AsNoTracking()
               .ToListAsync();

        var comlumHeadrs = new string[]
         {
             "Id",
             "Armazém",
             "Colaborador",
             "Criado Em",
             "Finalizado Em",
             "Objectivo",
             "Resultado Final",
             "Localização",
             "Etiquetas Por Inventariar",
             "Etiquetas Inventariadas",
             "Precisão",
             "Referência",
             "Etiqueta Não Encontrada"
         };

        byte[] result;

        using (var package = new ExcelPackage())
        {
            // add a new worksheet to the empty workbook

            var worksheet = package.Workbook.Worksheets.Add("Inventário"); //Worksheet name
            using (var cells = worksheet.Cells[1, 1, 1, 13]) //(1,1) (1,6)
            {
                cells.Style.Font.Bold = true;
            }

            //First add the headers
            for (var i = 0; i < comlumHeadrs.Count(); i++)
            {
                worksheet.Cells[1, i + 1].Value = comlumHeadrs[i];
            }

            //Add values
            var j = 2;
            foreach (var item in inventarios)
            {
                if (item.Labels.Count() != 0)
                {
                    foreach (var etiqueta in item.Labels)
                    {
                        worksheet.Cells[$"A{j}"].Value = item.Id;
                        worksheet.Cells[$"B{j}"].Value = item.Armazem;
                        worksheet.Cells[$"C{j}"].Value = item.Colaborador;
                        worksheet.Cells[$"D{j}"].Value = item.CreationDate.ToString("dd-mm-yyyy");
                        worksheet.Cells[$"E{j}"].Value = item.ClosedDate.Value.ToString("dd-mm-yyyy");
                        worksheet.Cells[$"F{j}"].Value = item.Objective;
                        worksheet.Cells[$"G{j}"].Value = item.Resultado;
                        worksheet.Cells[$"H{j}"].Value = item.Localizacao;
                        worksheet.Cells[$"I{j}"].Value = item.LabelsMissing;
                        worksheet.Cells[$"J{j}"].Value = item.LabelsStored;
                        worksheet.Cells[$"K{j}"].Value = item.Precision * 100;
                        worksheet.Cells[$"L{j}"].Value = etiqueta.Reference;
                        worksheet.Cells[$"M{j}"].Value = etiqueta.Name;

                        j++;
                    }
                }
                else
                {
                    worksheet.Cells[$"A{j}"].Value = item.Id;
                    worksheet.Cells[$"B{j}"].Value = item.Armazem;
                    worksheet.Cells[$"C{j}"].Value = item.Colaborador;
                    worksheet.Cells[$"D{j}"].Value = item.CreationDate.ToString("dd-mm-yyyy");
                    worksheet.Cells[$"E{j}"].Value = item.ClosedDate.Value.ToString("dd-mm-yyyy");
                    worksheet.Cells[$"F{j}"].Value = item.Objective;
                    worksheet.Cells[$"G{j}"].Value = item.Resultado;
                    worksheet.Cells[$"H{j}"].Value = item.Localizacao;
                    worksheet.Cells[$"I{j}"].Value = item.LabelsMissing;
                    worksheet.Cells[$"J{j}"].Value = item.LabelsStored;
                    worksheet.Cells[$"K{j}"].Value = item.Precision * 100;
                    worksheet.Cells[$"L{j}"].Value = "";
                    worksheet.Cells[$"M{j}"].Value = "";

                    j++;
                }
            }
            result = package.GetAsByteArray();
        }

        return File(result, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml", $"inventario{id}.xlsx");
    }
公共异步任务OnGetDownloadExcel(int id)
{
var inventarios=wait_context.Localizations
.其中(l=>l.InventoryRecordId==id)
.选择(ir=>新建
{
ir.InventoryRecord.Id,
Armazem=ir.InventoryRecord.Warehouse.Name,
Colaborador=ir.InventoryRecord.User.Name,
ir.InventoryRecord.CreationDate,
ir.InventoryRecord.ClosedDate,
ir.InventoryRecord.Warehouse.Objective,
Resultado=(ir.InventoryRecord.Localizations.Sum(l=>l.Precision)/ir.InventoryRecord.Localizations.Count())*100,
Localizacao=ir.Name,
ir.Labels失踪,
红外标签,
红外精密度,
红外标签
})
.AsNoTracking()
.ToListAsync();
var comlumHeadrs=新字符串[]
{
“身份证”,
“阿玛兹”,
“Colaborador”,
“克里亚多埃姆”,
"最后定稿",,
“目标”,
“最终结果”,
“Localizaão”,
“发明家的Etiquetas”,
“发明的Etiquetas”,
“普里西斯科”,
“参考”,
“Etiqueta Não Encontrada”
};
字节[]结果;
使用(var package=new ExcelPackage())
{
//将新工作表添加到空工作簿
var worksheet=package.Workbook.Worksheets.Add(“Inventário”);//工作表名称
使用(变量单元格=工作表单元格[1,1,1,13])/(1,1)(1,6)
{
cells.Style.Font.Bold=true;
}
//首先添加标题
对于(var i=0;i
编辑

这是我的边缘版本

版本80.0.361.66(正式版本)(64位)

不管怎样,也许这不是一个合适的地方问这个问题,但我不知道在哪里可以报告Edge的问题

这张图片是当我单击按钮时显示的,请求是底部的最后一项,正如您所看到的,没有问题


请指定您的Edge版本…@Smankusors我在Edge的问题上发布了它,如果您按F12并查看网络流量,您是否看到延迟?您是否检查了浏览器设置?微软喜欢自动做那些安全方面的事情。@Jackal如果是这样的话,那么我会认为这是一个边缘问题,而不是你的问题。你说它在Chrome和Firefox上运行得很好,这让我相信它的优势是在下载文件之前做额外的事情。例如,您可以进入Edge中的隐私/安全设置,并可以修改病毒/恶意下载。默认情况下,这些都处于启用状态。