网站能正常访问,css、js报404。
Startup配置如下:
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
else
{
app.UseExceptionHandler("/Home/Error");
}
//
app.UseIdentityServer();
//添加静态资源访问
app.UseStaticFiles();
//添加mvc默认路由
app.UseMvcWithDefaultRoute();
}
标签:
asp.net core
相关问题
- ASP.NET Core ConfigureServices 中从 appsettings.json
- .Net5 强制https请求重复跳转问题
- HttpContext.Items["Properties"]全局获取
- asp.net core 连接Oracle数据,异常,无法正常open
- 博客园的服务怎么实现预热后加入K8S集群的
会不会是大小写的问题?linux是区分大小写的
首先 publish,dotnet xxx.dll 要在 dll所在目录 着实不方便
我已经改成 配置的了
https://github.com/Microshaoft/MsSqlCodeDiffVersioning/blob/master/MsSqlCodeDiffVersioning/Startup.cs
https://github.com/Microshaoft/MsSqlCodeDiffVersioning/blob/master/MsSqlCodeDiffVersioning/wwwrootpaths.json
app.UseDefaultFiles
(
new DefaultFilesOptions()
{
DefaultFileNames =
{
"index.html"
}
}
);
//兼容 Linux/Windows wwwroot 路径配置
var wwwroot = GetExistsPaths
(
"wwwrootpaths.json"
, "wwwroot"
)
.FirstOrDefault();
if (wwwroot.IsNullOrEmptyOrWhiteSpace())
{
app.UseStaticFiles();
}
else
{
app
.UseStaticFiles
(
new StaticFileOptions()
{
FileProvider = new PhysicalFileProvider
(
wwwroot
)
, RequestPath = ""
}
);
}