How to allow font as static files in ASP.NET Core?

Viewed 1872

I'm currently working on a web application(ASP.NET Core, razor pages) and I have fonts on my 'www' folder since they're static files, but once the application is running it gives me a 404 error enter image description here

currently I have this on my Startup.cs

public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Error");
                app.UseHsts();
            }

            app.UseHttpsRedirection();

            StaticFileOptions options = new StaticFileOptions();
            Microsoft.AspNetCore.StaticFiles.FileExtensionContentTypeProvider typeProvider = new Microsoft.AspNetCore.StaticFiles.FileExtensionContentTypeProvider();
            if (!typeProvider.Mappings.ContainsKey(".woff2"))
            {
                typeProvider.Mappings.Add(".woff2", "application/font-woff2");
            }
            options.ContentTypeProvider = typeProvider;
            app.UseStaticFiles(options);
            //app.UseStaticFiles();
            app.UseCookiePolicy();

            app.UseMvc();




        }
0 Answers
Related