404 with static content in Razor Class Library (RCL)

后端 未结 4 543
渐次进展
渐次进展 2021-01-03 16:31

I am having difficulties implementing static files in razor class library (.net Core 3.1) that are consumed by an ASP.NET Core (v3.1) application.

When trying to acc

4条回答
  •  忘掉有多难
    2021-01-03 17:36

    I follow this article and it work well. https://dev.to/j_sakamoto/how-to-deal-with-the-http-404-content-foo-bar-css-not-found-when-using-razor-component-package-on-asp-net-core-blazor-app-aai

    In the Program.cs add in the StaticWebAssetsLoader to include the static file and it able load the css and javascript in the Razor library class

            public static IHostBuilder CreateHostBuilder(string[] args) =>
                Host.CreateDefaultBuilder(args)
                    .ConfigureWebHostDefaults(webBuilder =>
                    {
                        webBuilder.UseStartup();
                        webBuilder.ConfigureAppConfiguration((ctx, cb) =>
                        {
                            StaticWebAssetsLoader.UseStaticWebAssets(
                              ctx.HostingEnvironment,
                              ctx.Configuration);
                        });
                    });
    

提交回复
热议问题