我正在尝试从/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
发布评论