Showing results for 
Search instead for 
Did you mean: 
Ground Controller Lvl 1
Message 1 of 2

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.

1 Reply
Commander Lvl 2
Message 2 of 2

Re: Relative path to StaticFiles

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?

Please follow-up to let us know how you made out. For good karma, mark a reply as the answer if it helped!