CSS 在 IIS .net 核心 wwwroot 上找不到文件夹
CSS folder not found on IIS .net core wwwroot
不知何故,我决定在几个小时后将 .net core 2.2 与 vue+vuetify 结合起来失败后,分别构建我的网站 API 和客户端。
我使用 Vue CLI 构建客户端,配置如下:
module.exports = {
publicPath: process.env.NODE_ENV === 'production' ? '/joblist/' : '/',
}
然后将dist
文件夹的内容放到.net core项目的wwwroot
文件夹中,我使用下面的代码启用UseStaticFiles
:
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
else
{
app.UseHsts();
}
app.UseDefaultFiles();
app.UseStaticFiles();
app.UseMvc();
}
当我将 APP URL 设置为 http://localhost:49602/joblist
进行调试时,一切看起来都很完美。但是不知何故,当我发布到我的服务器 myserver/joblist
时,服务器无法提供 EVERYTHING 放置在 wwwroot/css
文件夹中的服务,所以网站看起来很难看。
起初,我以为问题出在 wwwroot 路径或类似的问题,但我可以完美地浏览到 wwwroot/js
文件夹,所以我尝试将 wwwroot/css
文件夹重命名为 wwwroot/notcss
, 这次网站运行完美。
谁能帮我解决这个问题?
更新:
wwwroot/css
和wwwroot/js
在服务器上完美存在。
- 我可以打开
wwwroot/js
文件夹中的任何文件,但不能打开任何文件
wwwroot/css
文件夹中的文件。
- 现在,我通过创建一个名为
wwwroot/notcss
的硬 link(可以是任何名称)来使用解决方法,然后将 index.html
文件中的任何 /css/*
引用替换为 /notcss/*
更新 2
这是我在浏览 CSS 文件夹
中的任何一个文件时在浏览器上收到的错误
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
一定是配置有误,尝试浏览到您服务器上的 C:\Windows\System32\inetsrv\config
,查找名为 applicationHost.config
的文件,打开该文件然后搜索 css
文本。如果你看到一些可疑的配置就删除它,不要忘记先备份它。
不知何故,我决定在几个小时后将 .net core 2.2 与 vue+vuetify 结合起来失败后,分别构建我的网站 API 和客户端。
我使用 Vue CLI 构建客户端,配置如下:
module.exports = {
publicPath: process.env.NODE_ENV === 'production' ? '/joblist/' : '/',
}
然后将dist
文件夹的内容放到.net core项目的wwwroot
文件夹中,我使用下面的代码启用UseStaticFiles
:
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
else
{
app.UseHsts();
}
app.UseDefaultFiles();
app.UseStaticFiles();
app.UseMvc();
}
当我将 APP URL 设置为 http://localhost:49602/joblist
进行调试时,一切看起来都很完美。但是不知何故,当我发布到我的服务器 myserver/joblist
时,服务器无法提供 EVERYTHING 放置在 wwwroot/css
文件夹中的服务,所以网站看起来很难看。
起初,我以为问题出在 wwwroot 路径或类似的问题,但我可以完美地浏览到 wwwroot/js
文件夹,所以我尝试将 wwwroot/css
文件夹重命名为 wwwroot/notcss
, 这次网站运行完美。
谁能帮我解决这个问题?
更新:
wwwroot/css
和wwwroot/js
在服务器上完美存在。- 我可以打开
wwwroot/js
文件夹中的任何文件,但不能打开任何文件wwwroot/css
文件夹中的文件。 - 现在,我通过创建一个名为
wwwroot/notcss
的硬 link(可以是任何名称)来使用解决方法,然后将index.html
文件中的任何/css/*
引用替换为/notcss/*
更新 2
这是我在浏览 CSS 文件夹
中的任何一个文件时在浏览器上收到的错误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
一定是配置有误,尝试浏览到您服务器上的 C:\Windows\System32\inetsrv\config
,查找名为 applicationHost.config
的文件,打开该文件然后搜索 css
文本。如果你看到一些可疑的配置就删除它,不要忘记先备份它。