ASP.NET Core 3.1

编程入门 行业动态 更新时间:2024-10-10 09:17:17
本文介绍了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:

我在做什么错了?

我在 ASP.NET Core中的静态文件 .

推荐答案

我在这里找到了答案.基本上,我必须为.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

本文发布于:2023-08-03 04:39:12,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1284027.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:NET   ASP   Core

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!