.net Core 生产环境报错 MIME

   because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled.css

   主要没有找到对应的Javascript 文件当成text/html 解析了,缘由是项目使用资源压缩html

   解决办法:json

  一、找到项目bundleconfig.json 文件   配置生产环境与开发环境所调用的JS、CSSapp

{
    "outputFileName": "wwwroot/css/site.min.css",
    "inputFiles": [
      "wwwroot/css/site.css"
    ]
 },
{
    "outputFileName": "wwwroot/js/site.min.js",
    "inputFiles": [
      "wwwroot/js/js.css"
    ]
 }

  二、cshtml 文件视图中经过 Environment 标签,分别定义开发预演和生产环境加载对应的资源文件。spa

 <environment names="Development">
    <link rel="stylesheet" href="~/css/site.css" />
    <script src="~/js/site.js" asp-append-version="true"></script>
</environment>
<environment names="Staging,Production">
    <link rel="stylesheet" href="~/css/site.min.css" asp-append-version="true" />
    <script src="~/js/site.min.js" asp-append-version="true"></script>
</environment>
相关文章
相关标签/搜索