Unable to load css and js on areas

Theolyn 1 Reputation point
2022-11-21T09:50:41.503+00:00

Im learning asp dotnet core using a template. I have been having problem loading css and js on areas. It was working when everything was on top level directory now its not working anymore. I tried the overriding UseStaticFiles still didnt work. The url poing to https://localhost:7103/admin/student/assets/css/bootstrap.min.css is giving 404 instead of the https://localhost:7103/assets/css/bootstrap.min.css which is the correct one and i was hoping for262563-css.png262510-jetbrains.png262539-js.png262593-ui.png262460-untitled.png

ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
4,596 questions
ASP.NET
ASP.NET
A set of technologies in the .NET Framework for building web applications and XML web services.
3,502 questions
JavaScript API
JavaScript API
An Office service that supports add-ins to interact with objects in Office client applications.
994 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Pablo Gabriel Mederos Caballero 1 Reputation point
    2022-11-21T12:15:12.97+00:00

    Hi!

    I can see your assets folder are not in the wwwroot folder of your project, then if you're using the ~ operator, your application cannot find the style file.

    You can try moving all your assets to your wwwroot folder.

    https://learn.microsoft.com/en-us/previous-versions/aspnet/ms178116(v=vs.100)

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.