iisasp.net-coreiis-7.5osm.pbf

mapbox files pbf blocked IIS server


PBF (street map mapbox vector files) files are not allowed to be served /downloaded from IIS (2008 R8) and I need them to be.

The background

PBFs are served OK when using the react development server

//Startup.cs
if (env.IsDevelopment())
{
   spa.UseReactDevelopmentServer(npmScript: "start");
}

These files will appear on the map correctly.

However when deploying the .NET Core app to IIS with

ASPNETCORE_ENVIRONMENT = production

set. These files are essentially blocked.

I have added the MIME type

enter image description here

I believe this is an IIS thing as like I say, on the react server in development they load fine.

Any clues as of why they still won't download?

Thanks


Solution

  • Basically IIS virtual directories aren’t supported in .net core. Due to the way .net core projects are served in IIS using a reverse proxy. So in the startup.cs file, do something like this:

            // Configure the virtual directory
            app.UseStaticFiles(new StaticFileOptions {
                FileProvider = new PhysicalFileProvider(@"\\Server\Directory\.."),
                RequestPath = "/NameOfDirectory",
                ContentTypeProvider = provider,
                OnPrepareResponse = (context) => {
                    if (!context.Context.User.Identity.IsAuthenticated) {
                        context.Context.Response.Redirect("LoginPage");
                    }
                }
            });