'Blazor-server-side can't see GLTF files
i have my blazor app hosted on azure with iis
got some GLTF file i want to access with three.js but its like my app can't see any of my GLTF files.
i have added a virtual directory inside my blazor app in IIS manager. (E://Output) is added inside IIS as a virtual folder next to wwwroot
if i go to https://xxxxx.com/output/637650602249582109_Output/VisData/room.bin (this file exist fine, and it will start downloading it)
if i go to https://xxxxx.com/output/637650602249582109_Output/VisData/scene.gltf it gives me a 404 ..
i have tried to add this in my startup:
app.UseStaticFiles();
app.UseStaticFiles(new StaticFileOptions
{
ServeUnknownFileTypes = true,
DefaultContentType = "text/plain"
});
it kinda helped with files i included in the projects wwwroot folder (wwwroot/VisData/scene.gltf)
https://xxxxx.com/VisData/scene.gltf
But what am I doing wrong with the files i have includes thru a virtual drive?
Solution 1:[1]
Solution 2:[2]
This can be done by dependency injection, just add the following to your Program.cs
.
using Microsoft.AspNetCore.StaticFiles;
...
builder.Services.Configure<StaticFileOptions>(options =>
{
options.ContentTypeProvider = new FileExtensionContentTypeProvider
{
Mappings =
{
[".gltf"] = "model/gltf+json",
[".glb"] = "model/gltf-binary",
[".bin"] = "application/octet-stream"
}
};
});
Full docs with an alternative option:
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Nicola Biada |
Solution 2 | StudioLE |