0

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

user3428422
  • 4,300
  • 12
  • 55
  • 119
  • What details can you share about how they are blocked? Do you get an error message? Have you checked the IIS logs? %SystemDrive%\inetpub\logs\LogFiles – Rich-Lang Apr 08 '19 at 20:53

1 Answers1

0

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");
                }
            }
        });
user3428422
  • 4,300
  • 12
  • 55
  • 119