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?
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744649766a4585831.html
评论列表(0条)