Skip to content

*.yml files not served and end up with a 404 #19931

@Carl-Hugo

Description

@Carl-Hugo

Is your feature request related to a problem? Please describe.

I'm trying to query a YAML file over HTTP (whatever.yml), but the server always returns 404. It works when I change the file extension to json or txt. The file is in the wwwroot folder.

The application is a Blazor WebAssembly project, with no server code. I'm running the project using dotnet watch run; the result is the same when I dotnet run.

Describe the solution you'd like

Give application developers more control over what type of files are served, using configuration.

Assuming that the server returns 404 because no mime-type/mapping for .yml is registered in FileExtensionContentTypeProvider.cs, what about allowing us to add mime-types to the appsettings.json and to the launchSettings.json?

Maybe something like:

{
  "staticFiles": {
    "contentTypeProvider": {
      "mappings": {
        ".yml": "application/x-yaml", //<-- Add .yml
        ".mp4": null //<-- Remove .mp4
      }
    }
  }
}

Additional context

I don't think that the hacky FileExtensionContentTypeProvider workaround from the documentation is good enough. Moreover, that does not work with Blazor wasm (well if it does, please explain to me what I missed; I'm still new to Blazor wasm).

Metadata

Metadata

Labels

DoneThis issue has been fixedarea-blazorIncludes: Blazor, Razor ComponentsenhancementThis issue represents an ask for new feature or an enhancement to an existing onefeature-blazor-wasmThis issue is related to and / or impacts Blazor WebAssembly

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions