ASP.NET Core 3.1-无法加载资源:服务器响应状态为404() [英] ASP.NET Core 3.1 - Failed to load resource: the server responded with a status of 404 ()

查看:221
本文介绍了ASP.NET Core 3.1-无法加载资源:服务器响应状态为404()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从/wwwroot/3d_models 文件夹位置加载资源文件.

I'm trying to load a resource file from the /wwwroot/3d_models folder location.

在Startup.cs中,我启用了 app.UseStaticFiles(); ,并添加了以下代码段:

In the Startup.cs I enabled app.UseStaticFiles(); and added the following snippet:

app.UseStaticFiles(new StaticFileOptions()
{
    FileProvider = new PhysicalFileProvider(Path.Combine(env.WebRootPath, @"3d_models")),
    RequestPath = new AspNetCore.Http.PathString("/models")
});

app.UseDirectoryBrowser(new DirectoryBrowserOptions()
{
    FileProvider = new PhysicalFileProvider(Path.Combine(env.WebRootPath, @"3d_models")),
    RequestPath = new AspNetCore.Http.PathString("/models")
});

/wwwroot 文件夹下(在解决方案资源管理器中),我添加了资源文件:

Under the /wwwroot folder (in solution explorer), I added the resource file:

但是,我仍然遇到此404错误.有趣的是,当我尝试直接从浏览器转到文件时,我还会收到以下错误:

Yet still, I'm getting this 404 error. Interestingly, when I try to go to the file directly from the browser, I also get the following error:

我在做什么错了?

我在 推荐答案

我在这里找到了答案.基本上,我必须为.glb文件类型设置mimetype/mapping.

I found the answer here. Basically, I had to set the mimetype/mapping for the .glb file type.

请参见 静态ASP.NET Core中的文件 .

这篇关于ASP.NET Core 3.1-无法加载资源:服务器响应状态为404()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆