Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS folder not found on IIS .net core wwwroot

Somehow I decided to build my web API and client separately after several hours failed to combine .net core 2.2 with vue+vuetify.

I build the client using Vue CLI, with this config:

module.exports = {
  publicPath: process.env.NODE_ENV === 'production' ? '/joblist/' : '/',
}

Then place the content of dist folder to wwwroot folder on .net core project, I use below code to enable UseStaticFiles:

public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
    if (env.IsDevelopment())
    {
        app.UseDeveloperExceptionPage();
    }
    else
    {
        app.UseHsts();
    }

    app.UseDefaultFiles();
    app.UseStaticFiles();
    app.UseMvc();
}

Everything looks perfect when I debug with APP URL set to http://localhost:49602/joblist. But somehow when I publish to my Server, which is myserver/joblist, the server can't serve EVERYTHING placed inside wwwroot/css folder, so the site looks ugly.

At first, I thought the problem is the wwwroot path or something like that, but I can browse to wwwroot/js folder perfectly, so I try to rename wwwroot/css folder to wwwroot/notcss, the site works perfectly this time.

Can anybody help me with this problem?

UPDATE:

  • The wwwroot/css and wwwroot/js is perfectly exist on the server.
  • I can open any file inside wwwroot/js folder but can not open any file inside wwwroot/css folder.
  • For now, I use a workaround by creating a hard link named wwwroot/notcss (can be any) then replace any /css/* reference in index.html file to /notcss/*

UPDATE 2

Here is the error I received on the browser when browse on one of any file in CSS folder

HTTP Error 404.0 - Not Found

The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.

Detailed Error Information:

Module           IIS Web Core
Notification     MapRequestHandler
Handler          StaticFile
Error Code       0x80070002
Requested URL    http://localhost:80/joblist/css/app.14044b2f.css
Physical Path    C:\inetpub\wwwroot\joblist\css\app.14044b2f.css
Logon Method     Anonymous
Logon User       Anonymous
like image 242
SIRS Avatar asked Apr 12 '19 01:04

SIRS


People also ask

What is wwwroot folder in .NET Core?

By default, the wwwroot folder in the ASP.NET Core project is treated as a web root folder. Static files can be stored in any folder under the web root and accessed with a relative path to that root.

How do I install wwwroot folder?

Right-click on the project and “Add” a folder. Name it wwwroot, Visual Studio automatically generates an icon on wwwroot folder. Under wwwroot folder, “Add” 3 more folders with the names CSS, JS and lib.

Where can I find wwwroot folder?

Right-click the Web application you want more information about, such as SharePoint (80), and then click Properties. In the Default Web Site Properties window, click the Home Directory tab. The Local Path field in this tab shows the Web application root folder.

How do I serve a static file in NET Core?

To serve static files from an ASP.NET Core app, you must configure static files middleware. With static files middleware configured, an ASP.NET Core app will serve all files located in a certain folder (typically /wwwroot).


1 Answers

There must be any some misscongured config, try to browse to C:\Windows\System32\inetsrv\config on your server, looks for a file named applicationHost.config open the file then search for css text. if you see some suspicious config just delete it, don't forget to backup it first.

like image 145
nyongrand Avatar answered Sep 24 '22 06:09

nyongrand