Reputation: 53
I have subfolders of JS and CSS in my wwwroot folder of asp.net core razor page application. Application works fine in local environment, but while deployment of the project on IIS, the wwwroot folder does not contain any subfolders or files in it.
Even if I manually upload the folders and files to wwwroot folder, it doesn't work and it does not load the JS and CSS files in the browser.
Note that I do not have "Environment" tags in my application.
Upvotes: 1
Views: 4020
Reputation: 160
In my scenario I was adding MVC to my .Net 5 API
The solution was to add
app.UseStaticFiles();
to the Startup.cs
Upvotes: 0
Reputation: 12749
Try to edit the .csproj file of your asp.net core project:
Remove all the ItemGroup tags and their contents then add this
<ItemGroup>
<None Include="wwwroot\*" />
</ItemGroup>
You could refer this link for more detail:
Visual Studio publish profiles for ASP.NET Core app deployment
Upvotes: 1
Reputation: 648
There are two ways of setting the js/css path
Absolute Path is, you have to give proper path in web server .
http://<website name>/css/site.css
Relative Path is, you can give file page relative to current page.
let say your page is from http://<website name>/index.html
relative path will be ./css/site.css
Better you try to access js or css file from browser. may be these folders do not have right permission to access.
if you open Dev Tool, you can see the error in Network tab or console. Base on HTTP code, you can decide what has happened
Upvotes: 0