--- title: ASP.NET Core Blazor static files author: guardrex description: Learn how to configure and manage static files for Blazor apps. monikerRange: '>= aspnetcore-3.1' ms.author: riande ms.custom: mvc ms.date: 01/27/2021 no-loc: [Home, Privacy, Kestrel, appsettings.json, "ASP.NET Core Identity", cookie, Cookie, Blazor, "Blazor Server", "Blazor WebAssembly", "Identity", "Let's Encrypt", Razor, SignalR] uid: blazor/fundamentals/static-files --- # ASP.NET Core Blazor static files *This article applies to Blazor Server.* To create additional file mappings with a or configure other , use **one** of the following approaches. In the following examples, the `{EXTENSION}` placeholder is the file extension, and the `{CONTENT TYPE}` placeholder is the content type. * Configure options through [dependency injection (DI)](xref:blazor/fundamentals/dependency-injection) in `Startup.ConfigureServices` (`Startup.cs`) using : ```csharp using Microsoft.AspNetCore.StaticFiles; ... var provider = new FileExtensionContentTypeProvider(); provider.Mappings["{EXTENSION}"] = "{CONTENT TYPE}"; services.Configure(options => { options.ContentTypeProvider = provider; }); ``` Because this approach configures the same file provider used to serve `blazor.server.js`, make sure that your custom configuration doesn't interfere with serving `blazor.server.js`. For example, don't remove the mapping for JavaScript files by configuring the provider with `provider.Mappings.Remove(".js")`. * Use two calls to in `Startup.Configure` (`Startup.cs`): * Configure the custom file provider in the first call with . * The second middleware serves `blazor.server.js`, which uses the default static files configuration provided by the Blazor framework. ```csharp using Microsoft.AspNetCore.StaticFiles; ... var provider = new FileExtensionContentTypeProvider(); provider.Mappings["{EXTENSION}"] = "{CONTENT TYPE}"; app.UseStaticFiles(new StaticFileOptions { ContentTypeProvider = provider }); app.UseStaticFiles(); ``` * You can avoid interfering with serving `_framework/blazor.server.js` by using to execute a custom Static File Middleware: ```csharp app.MapWhen(ctx => !ctx.Request.Path .StartsWithSegments("_framework/blazor.server.js", subApp => subApp.UseStaticFiles(new StaticFileOptions(){ ... }))); ```