申请SSL证书后内容处置为空,为什么?

时间:2018-12-12 09:07:12

标签: c# angularjs azure ssl-certificate asp.net-core-webapi

我们已经实现了一些下载功能。我们正在api端设置内容配置。这样,我们的UI将从内容配置中获取文件名。

在添加SSL证书并将站点移至特定于域的链接之前,此方法运行良好。

现在,内容处置又回到了null,并且文件下载时名称为null,没有扩展名。

下面是我们下载文件的代码。

public IActionResult DownloadFile(int ID)
{
    try
    {
        if (ValidateUsrToken())
        {
            using (ExcelPackage package = BAL.DownloadFile(ID))
            {
                string fileName = Uri.EscapeDataString(package.File.Name);

                System.Net.Mime.ContentDisposition cd = new System.Net.Mime.ContentDisposition
                {
                    FileName = fileName,
                };

                Response.Headers.Add("Content-Disposition", cd.ToString());

                return File(package.GetAsByteArray(), "application /vndopenxmlformats-officedocument.spreadsheetml.sheet");
            }
        }
        else throw new NullReferenceException();
    }
    catch (Exception ex)
    {
        throw ex;
    }
}

UI代码

const disposition = res.headers.get('content-disposition') || '';
if (disposition && disposition.indexOf('attachment') !== -1) {
   const filenameRegex = /filename[^;=\n]*=((['"]).*?\2|[^;\n]*)/;
   const matches = filenameRegex.exec(disposition);
   if (matches != null && matches[1]) {
      filename = matches[1].replace(/['"]/g, '');
      filename = decodeURIComponent(filename);
   }
} 

我们的api和UI在Azure云上实现。

对此有任何帮助。

0 个答案:

没有答案