Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert Blazor Server App to Blazor Web-assembly approach

I want to develop an SPA project by Blazor technology.

Due to complexity of debugging the Blazor Web-assembly application, I would like to first create it as a server-side app, and then later change it to a Web-assembly application app.

Is this possible? If so, after I have successfully gotten the Server-side Blazor project to work, what changes will I need to make, to get the same functionality working with the WebAssembly project?

Also, are there any particular approaches or technologies I should avoid in my Server-side Blazor project, because they have no equivalent when using WebAssembly?

like image 382
Mohamad Jalalian Avatar asked Mar 07 '20 12:03

Mohamad Jalalian


People also ask

What is difference between Blazor server and Blazor WebAssembly?

Blazor Server apps have direct access to server and network resources where the app is executing. Because Blazor WebAssembly apps execute on a client, they don't have direct access to server and network resources.

Does Blazor compile to WebAssembly?

Blazor WebAssembly supports ahead-of-time (AOT) compilation, where you can compile your . NET code directly into WebAssembly. AOT compilation results in runtime performance improvements at the expense of a larger app size.

Is Blazor WebAssembly better than angular?

Support: The size of the community using Angular is very high when compared to Blazor. So, the chances of finding a solution to the problem we face during the app development are high for Angular. Use of TypeScript: TypeScript has attributes that are way better than JavaScript's.


1 Answers

For the most part, your Blazor components should be able to migrate from Server to Webassembly with few or no changes.

If your Blazor Server application doesn't require data from outside your application (e.g. database calls), and it doesn't use any APIs that aren't supported in the browser (e.g. System.Security.Cryptography), then you may be able to migrate to Blazor Webassembly without any changes to your components.

If your Blazor Server application does require data from outside the browser, then those services will need to be hosted elsewhere and called from your components via Http requests (see Call a web API from ASP.NET Core Blazor). There are a couple of good options for your Blazor Webassembly back-end, the most common of which is the Blazor Webassembly hosted template.enter image description here

If you'd rather serve your Webassembly app as a static web application, you can instead move your back-end services to a serverless function application. There are a variety of options for that, the most convenient of which (in my opinion) is using Azure Static Web Apps with .NET and Blazor

like image 185
HillPhelmuth Avatar answered Oct 14 '22 03:10

HillPhelmuth