webDoorView: ripristino situazione a ultima modifica (da rivedere x proj cs)
This commit is contained in:
@@ -0,0 +1,62 @@
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using Microsoft.AspNetCore.Components.Web;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.FileProviders;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
// configuration setup
|
||||
Microsoft.Extensions.Configuration.ConfigurationManager configuration = builder.Configuration;
|
||||
|
||||
// Add services to the container.
|
||||
builder.Services.AddRazorPages();
|
||||
builder.Services.AddServerSideBlazor();
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
|
||||
var provider = new Microsoft.AspNetCore.StaticFiles.FileExtensionContentTypeProvider();
|
||||
// NOTE: Add new mappings
|
||||
provider.Mappings[".3dm"] = "model"; // NOTE: add the extension (with period) and its type
|
||||
|
||||
|
||||
app.UseStaticFiles(new StaticFileOptions // NOTE: replace the line app.UseStaticFiles(); with this block of code
|
||||
{
|
||||
ContentTypeProvider = provider
|
||||
});
|
||||
|
||||
// gestione static files x modelli 3D: https://learn.microsoft.com/en-us/aspnet/core/fundamentals/static-files?view=aspnetcore-8.0
|
||||
string path3dm = configuration.GetValue<string>("ServerConf:path3dm") ?? configuration.GetValue<string>("OptConf:path3dm") ?? "";
|
||||
if (!string.IsNullOrEmpty(path3dm))
|
||||
{
|
||||
// verifico esista folder disegni
|
||||
if (Directory.Exists(path3dm))
|
||||
{
|
||||
// gestione cartella x PDF
|
||||
app.UseStaticFiles(new StaticFileOptions
|
||||
{
|
||||
FileProvider = new PhysicalFileProvider(path3dm),
|
||||
RequestPath = "/3dm",
|
||||
ContentTypeProvider = provider
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Configure the HTTP request pipeline.
|
||||
if (!app.Environment.IsDevelopment())
|
||||
{
|
||||
app.UseExceptionHandler("/Error");
|
||||
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
|
||||
app.UseHsts();
|
||||
}
|
||||
|
||||
app.UseHttpsRedirection();
|
||||
|
||||
app.UseStaticFiles();
|
||||
|
||||
app.UseRouting();
|
||||
|
||||
app.MapBlazorHub();
|
||||
app.MapFallbackToPage("/_Host");
|
||||
|
||||
app.Run();
|
||||
Reference in New Issue
Block a user