简体   繁体   中英

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 

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM