admin管理员组文章数量:1391999
When my app initially loads all is ok and in Chrome, console errors are 0. When I press the browser refresh, I receive the following error:
Refused to execute script from 'http://localhost:50001/dist/vendor-es5.js' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled.
I also receive the same error for 'main-es5.js'
The error is generated from my index.cshtml file in here I have:
@section scripts {
<script src="~/dist/vendor-es5.js" asp-append-version="true"></script>
<script src="~/dist/main-es5.js" asp-append-version="true"></script>
}
changing the
<script type="text/javascript" src="~/dist/vendor-es5.js" asp-append-version="true"></script>
still gives the same error.
my index.cshtml file resides in views/home the dist directory resides in clientapp
if I change the reference on the script src to be ./clientapp/dist/vendor-es5.js for instance, then the app still loads correctly first time in, but then when I press the refresh, I get no console errors, but the page still doesn't refresh. Anybody have any ideas where I should go next.
When my app initially loads all is ok and in Chrome, console errors are 0. When I press the browser refresh, I receive the following error:
Refused to execute script from 'http://localhost:50001/dist/vendor-es5.js' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled.
I also receive the same error for 'main-es5.js'
The error is generated from my index.cshtml file in here I have:
@section scripts {
<script src="~/dist/vendor-es5.js" asp-append-version="true"></script>
<script src="~/dist/main-es5.js" asp-append-version="true"></script>
}
changing the
<script type="text/javascript" src="~/dist/vendor-es5.js" asp-append-version="true"></script>
still gives the same error.
my index.cshtml file resides in views/home the dist directory resides in clientapp
if I change the reference on the script src to be ./clientapp/dist/vendor-es5.js for instance, then the app still loads correctly first time in, but then when I press the refresh, I get no console errors, but the page still doesn't refresh. Anybody have any ideas where I should go next.
Share edited May 22, 2020 at 10:34 Liam 29.8k28 gold badges139 silver badges203 bronze badges asked May 22, 2020 at 9:33 bilporbilpor 3,9236 gold badges38 silver badges86 bronze badges 10-
1
seems like the webserver return incorrect MIME type for the
~/dist/vendor-es5.js
– IAfanasov Commented May 22, 2020 at 9:36 - @IAfanasov looking at the mime types in iis .js files are set to application/javascript – bilpor Commented May 22, 2020 at 10:06
- This is nothing to do with angular. This is a server side issue. You need to get your web server to return the correct mime type – Liam Commented May 22, 2020 at 10:33
- 1 This appears to have nothing to do with C# specifically. More likely an IIS issue. – ADyson Commented May 22, 2020 at 10:33
-
1
Wait;
script
? That's not a valid mime type – Liam Commented May 22, 2020 at 11:00
1 Answer
Reset to default 5First, please ensure that we have enabled the below HTTP
feature, which makes IIS can properly process requests for static files.
It may also have something to do with the setup of your client’s build tool, for example Webpack
.
Refused to execute script from because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled
In addition, in certain ReactJs applications, the usage of App.use
method also might be a reason for this type of issue.
app.use(express.static(__dirname + "/static"));
Please refer to the below links.
loading a bundle.js file from webpack changes mime type to text/html
Refused to execute script from because its MIME type (...) and strict MIME type (...)
Refused to execute script from because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled
Refused to execute script, strict MIME type checking is enabled?
本文标签: javascriptIIS returning texthtml for js filewhyStack Overflow
版权声明:本文标题:javascript - IIS returning texthtml for js file, why? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744649766a2617615.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论