Css "not found"

When a Blazor server app is “published”, it creates a web server that can run on the host and then you open the browser to see the application. Much like Electron, but with C#.

When I create a Blazor app on Windows, it runs in the IDE and stand-alone when published on Windows.
When I create a Blazor app on MacOS, it runs in the IDE, and stand-alone when published on MacOS.

When I create a Blazor app on Windows, with MacOS as the target, and then run it on MacOS, the server starts up fine, and the app can be seen in the browser, but it doesn’t “see” the css. Looking at the “source” in the browser, I can see the lines pointing to the CSS, and a 404 error. The paths and filenames are correct, but it’s not loading them.

Any idea why the browser cannot “see” the css?



It’s supposed to look like this:

There should be more information hidden somewhere as to what actual error occurred when loading the resource. I want to say the “Network” tab, but I don’t use the Safari debugger enough to say for sure.

If you find details on the error that occurred, it may help figure out how to fix it.

Thanks, Tim! How about Firefox? That’s the other browser I use…

With Firefox it is the Network tab. You’ll have to open up the debugger first, select the Network tab, then reload the page. Select the resource that erred, and it should open a view on the right side that has information. The Console tool might also contain some information as well.

In Safari, it says “404 (Not Found)” when I click on the red !.

Same with FF.

Well now you have more information! I’m not sure why that would happen though, so that’s the extent of my usefulness :frowning:

Ok, it’s a mystery to me. The files are right there where it’s looking for them.

just my WAG but isnt the name of the css wrong ?
it says css/site.css and in the file listing I dont see such a thing
I do see other css though

under the css folder.

that ones not expanded in the image so … hence why it was a WAG

is it also having issue with BlazorApp1.styles.css and bootstrap.min.css ?
they’re also marked in red
almost like the root of the site isnt right or something since it seems to not be finding several files

Yup. Trying to figure out the cause.

There’s literally NO .NET forums for MacOS users or any existing .NET forums that have any members that use Macs. .NET is SO Windows-centric. MacOS is just an afterthought.
As usual, I’m blazing new ground…

Is there any configuration file that can set the web root to a different directory than the one where the application is?

All these links show http:
Is there a certificate on the site?
If so, shouldn’t the URLs be https: ?

I ask because I went through hell with my own site this year (still not fully resolved tbh) , whereby a URL that used http: wouldnt work while one that had https: did, and some of this came down to caching and the use of Cloudflare as a CDN
(Sometimes the http URL would even return a file, but it might be months older than the actual current file.)

They show both. FF shows http:// and Safari shows https://
http:// automatically forwards to https:// with this configuration.
Remember it’s on a local machine, not a web server.

For the issue you were having, you need to add a configuration line in your apache or nginx setup to automatically forward http to https.

That’s possibly the issue, but I haven’t found such a config file so far…

WAG?

Wild A… Guess

1 Like

Alberto hit it :slight_smile:

1 Like