Relative path to StaticFiles

I have developed a .Net Core web application that I can launch both in Debug and Release modes in my development environment. Upon deployment onto a Windows Server, my CSS, JS and Image files are not loaded because the path to my webroot (where all these staticfiles are) seems different between development and production environments. In the Configure method of Startup.cs, I have app.UseStaticFiles.

What is the best means of synchronizing the two? 

BTW, this is how I reference my staticfiles in my views:

<script src="~/lib/jquery/dist/jquery-3.3.1.min.js"></script>
<link href="~/css/bootstrap.min.css" rel="stylesheet" />
<link href="~/lib/font-awesome/css/font-awesome.min.css" rel="stylesheet">

html, body {
      height: 100%;
      background-size: cover;
      background-image: url("/images/b2.jpg");
    }

In Development, these correctly access the lib, css, and images folders which are immediate subfolders of wwwroot.  No such luck in Production.

So where are the files on the prod server? E.g. you’re implying that “http://prod-server/images/b2.jpg” isn’t working - what does work?

Did you use CreateWebHostBuilder as mentioned here?  Are the server (dev vs prod) addresses different?

1 Like