1

I ran into a really odd issue where all of my js, css, images, ect. are not found on the server. However, everything does work fine locally.

Here is part of my layout with the scripts and css being loaded.

<head>
    <title>@ViewBag.Title</title>
    <meta name="description" content="@ViewBag.MetaDescription">
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    @await Component.InvokeAsync("GoogleAnalytics")

    <link rel="icon" href="~/img/Logo-small-background.png">
    <link rel="stylesheet" href="~/css/lib/bootstrap.min.css" />
    <link rel="stylesheet" href="~/css/fonts/ProximaNova/fonts.min.css" />
    <link rel="stylesheet" href="~/css/lib/font-awesome.min.css" />
    <link rel="stylesheet" href="~/css/site.css" />

    <script src="~/lib/jquery/dist/jquery.min.js"></script>
    <script src="~/js/lib/bootstrap.min.js"></script>
    <script src="~/js/lib/vue.min.js"></script>
    <script src="~/js/lib/lodash.min.js"></script>
    <script src="~/js/Shared.js"></script>
</head>

Screen shot of localhost paths: https://i.stack.imgur.com/QORkw.jpg

And screen shot of it from the server: https://i.stack.imgur.com/eYOBB.jpg

I believe I also have everything pathed right in my solution as well: https://i.stack.imgur.com/9tsUt.jpg

Here is my program.cs just to show that i am not overriding the default webRoot.

public static IWebHostBuilder CreateHostBuilder(string[] args) =>
            WebHost.CreateDefaultBuilder(args)
            .UseStructureMap()
            .UseUrls("http://*:5000")
            .UseStartup<Startup>();

Here are some shots when I try to navigate right to an img.

localhost: https://i.stack.imgur.com/EOlKf.jpg

Server: https://i.stack.imgur.com/QXAcC.jpg

If needed, I am running this on a Raspberry Pi running Ubuntu and Apache, although I don't think that would really matter in the case, but I am not sure.

Any help would be appreciated.

2 Answers2

1

Turns out it did have to do with my server.

I was trying to run my site locally using command like

dotnet /var/www/site/site.dll

When I would run that right on the server, it was running it as my Pi user which did not have access to all the folders.

Once I started up my server that is always running .net, that service was running as www-data so it did have access.

Otherwise I could have also just granted access my user when running manually.

0

~ means the home directory in Unix.

~ is only the home directory on local machines not running Windows.

HTML knows to handle ".." as parent and "." as current directory, but it treats "~" as a folder name. Thus, you might be getting 404s in the Console.

no ai please
  • 732
  • 3
  • 11
  • 24