neggenbe
neggenbe

Reputation: 1885

Blazor Server Side MIME type error for content JS file

I've create a base assembly BaseDll that compiles as a referenced project by my main Blazor Server Side MainBSSApp.

The base assembly contains a few JS functions that are located in the myJSFile.js file of the BaseDll assembly (I've added them into a BaseDll.wwwroot folder).

So I add the reference to my JS file in MainBSSApp/Shared/_Host.cshtml (I actually tried several places, result is always the same - I now have it in the <head> section):

<script src="_content/BaseDll/myJSFile.js"></script>

When I execute the MainBSSApp on my standard VS version (Windows) all seems to work fine. Now I'm trying to migrate the project on Ubuntu with VS Code. Views referenced by BaseDll as well as services are working fine. However, as soon as I call any JS method defined in the myJSFile.js, I do get an error because the function is not defined - and righ before that, I get the warning that `The scritp from "[...]/_content/BaseDll/myJSFile.js" was loaded even though its MIME type ("text/html") is not a valid JavaScript MIME type."

So I tried this fix but without luck (I tried both 777 and 705 permission, nothing changed)...

What am I doing wrong here?

Upvotes: 1

Views: 987

Answers (1)

neggenbe
neggenbe

Reputation: 1885

Solution is indeed to add the ./ before the _content

<script src="./_content/BaseDll/myJSFile.js"></script>

credits to @pcalkins and to the docs...

Upvotes: 1

Related Questions