Click here to Skip to main content
15,922,696 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm using a template and have successfully created the Index page using the app.UseStaticFiles() everything seems to work fine but then when I created new razor layout and visit the ourSerivces page the application sees like its unable to access the wwwroot file none of the text is formatted. What could be the problem. Than you very much in advance

Below is the link to the git repository

GitHub - martinzen/companyweb: Website that has general information for the company, ability to publish, change and update posts with categories. Users are able to login and create a job or book service for the laptop and see their previouse history [^]

What I have tried:

I have tried changing the location of the layout ourServices, didn't solve anything the I have tried changing the app.UseStaticFiles to point to the folder again nothing.
Posted
Updated 18-Dec-19 2:59am
v2

1 solution

The problem is with the way you reference the static files. For example:
HTML
<link href="css/bootstrap.min.css" rel="stylesheet">
That tries to load the stylesheet from a path relative to the current URL. That will only work when you're in the root of your site; as soon as you access a different controller or action, the relative path will stop working.

As shown in the documentation[^], you need to use app-relative paths:
HTML
<link href="~/css/bootstrap.min.css" rel="stylesheet">
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900