Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to publish Blazor WebAssembly with ASP.NET Core hosted

Tags:

c#

blazor

I would like to know how do I publish a Blazor WebAssembly application with ASP.Net Core Hosted checked. The big problem is that in the application they have 2 projects, and I don't know which one to publish, or how to merge between them when publishing.

like image 879
Gabriel Seles Avatar asked May 18 '20 21:05

Gabriel Seles


2 Answers

Publish the Server app.

When you look in its \bin\Release folder you will see the Client related DLLs as well.

Don't overthink it.

like image 139
Henk Holterman Avatar answered Nov 19 '22 20:11

Henk Holterman


You need to publish your Server project.

But it must have a reference to your Client's project.

In versions < 3.2.0 you must also register Blazor on your server application.

Here's how to register it in your server Startup (Replace Client with the proper namespace in your Blazor project):

    public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
    {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseBlazorDebugging();
            }
        app.UseStaticFiles();
        app.UseClientSideBlazorFiles<Client.Startup>();
        app.UseEndpoints(endpoints =>
        {
                endpoints.MapDefaultControllerRoute();
                endpoints.MapFallbackToClientSideBlazor<Client.Startup>("index.html");
         });
     }
like image 5
Gabriel Cappelli Avatar answered Nov 19 '22 20:11

Gabriel Cappelli