gpt4 book ai didi

asp.net-mvc - ASP MVC 资源解释为样式表,但使用 MIME 类型 application/javascript 进行传输

转载 作者:行者123 更新时间:2023-12-02 20:38:45 26 4
gpt4 key购买 nike

我习惯于引用我所有的 cssjs 文件,而不像这样捆绑:

<link rel='stylesheet' type='text/css' href='style.css'/>

但是由于我使用捆绑,我在 chrome 中收到以下错误消息:

Resource interpreted as Stylesheet but transferred with MIME type application/javascript: "http://localhost:9432/Assets/global/plugins/bootstrap/js/bootstrap.min.js".

我发现我应该将 Content-Type 设置为 application/javascript 但我不知道如何执行此操作。

您对解决此问题有何建议?

更新:

这是我的代码:

          bundles.Add(new StyleBundle("~/bundles/AdminStyle").Include(
"~/Assets/global/plugins/font-awesome/css/font-awesome.min.css",
"~/Assets/global/plugins/simple-line-icons/simple-line-icons.min.css",
"~/Assets/global/plugins/bootstrap/css/bootstrap-rtl.min.css",
"~/Assets/global/plugins/bootstrap-switch/css/bootstrap-switch-rtl.min.css",
"~/Assets/global/plugins/bootstrap-select/css/bootstrap-select-rtl.css",
"~/Assets/global/css/components-rounded-rtl.min.css",
"~/Assets/global/css/plugins-rtl.min.css",
"~/Assets/layouts/layout3/css/layout-rtl.min.css",
"~/Assets/layouts/layout3/css/themes/default-rtl.min.css",
"~/Assets/layouts/layout3/css/custom.css",
"~/Assets/global/plugins/bootstrap-social-button/css/bootstrap-social.css",
"~/Assets/global/plugins/bootstrap-toastr/toastr.min.css",
"~/Assets/global/css/Custom.css",
"~/Assets/global/css/helper.css"));

 bundles.Add(new StyleBundle("~/bundles/AdminScript").Include(
"~/Assets/global/plugins/bootstrap/js/bootstrap.min.js",
"~/Assets/global/plugins/js.cookie.min.js",
"~/Assets/global/plugins/jquery-slimscroll/jquery.slimscroll.min.js",
"~/Assets/global/plugins/jquery.blockui.min.js",
"~/Assets/global/plugins/bootstrap-switch/js/bootstrap-switch.min.js",
"~/Assets/global/scripts/app.min.js",
"~/Assets/layouts/layout3/scripts/layout.min.js",
"~/Assets/layouts/layout3/scripts/demo.min.js",
"~/Assets/layouts/global/scripts/quick-sidebar.min.js",
"~/Assets/layouts/global/scripts/quick-nav.min.js",
"~/Assets/global/plugins/bootstrap-select/js/bootstrap-select.min.js"));

最佳答案

您正在将 js 文件渲染为 <link rel="stylesheet" href="/bundles/....">

所以,在你的 cshtml 中,更改@Styles.Render("~/bundles/AdminScript")@Scripts.Render("~/bundles/AdminScript")

关于asp.net-mvc - ASP MVC 资源解释为样式表,但使用 MIME 类型 application/javascript 进行传输,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46443322/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com