Blazor Server App and Blazor WebAssembly App
Tags: blazor, aspnetcore, beginners, codenewbie
Published: 2022-03-27 17:14:47

---
title: Blazor Server App and Blazor WebAssembly App
published: true
description: 
tags: blazor, aspnetcore, beginners, codenewbie
//cover_image: https://direct_url_to_image.jpg
---
####Introduction
As you saw in this [blog post](https://dev.to/sabahshariq/getting-started-with-blazor-web-development-4c7k) when you try to an Blazor project in visual studio you will get two template Blazor Server App and Blezor WebAssembly. Now we will look into more details regarding this.
![hosting model](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cqfylw0hh5bxz405e7vo.png)

####Blazor Hosting Models:
Blazor Server and Blazor WebAssembly these two actually are hosting models i.e. how would you like to run your web app. Each hosting models have different tradeoffs. Regardless of the hosting model, the way you build Razor components is the same. When to use which hosting model it depends on your requirement.

*In simple term,* if you wish to build an application that have server client communication then Blazor Server hosting model would be preferred. And if we wish yourapplication to work offline then Blazor WebAssembly.

*In technical terms,* If your Blazor application doesn't require any data from outside of your application (e.g. database calls), and it doesn't use any APIs then you may choose Blazor Webassembly. And If your Blazor application does require data from outside the browser, then those services will need to be hosted elsewhere and called from your client via Http requests then you may choose Blazor Server.

####Blazor Server:
In Blazor server hosting model is basically an ASP.NET Core app where the app is executed on the server where functionality such as,
* Integrating a SQL Server database through Entity Framework take place.
* Client-side pages creation are done via Razor components or Razor pages.
* UI updates, event handling, and JavaScript calls are handled over a SignalR connection. This is how the browser communicates with the Blazor Server application.

As the execution takes place on server-side apps built on Blazor Server model will work on older browsers as there is no requirement for Web Assembly, only HTML and JavaScript.

####Blazor WebAssembly:
Blazor WebAssembly (WASM) apps run client-side in the browser on a WebAssembly-based .NET runtime where functionality such as, 

* Dependencies, and the .NET runtime are downloaded to the browser.
* App is executed directly on the browser UI thread. UI updates and event handling occur within the same process.
* App's assets are deployed as static files to a web server or service capable of serving static content to clients.

As Web Assembly runs on the client, inside the browser, No need for a constant connection with a server for the application to work. When the network connection to the server is lost, the client app can continue to function in off-line.

Following are the project folder structure in visual studio for each hosting model
######Blazor Server App:
![Blazor Server](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lzjacw5bcbugq53u3iii.png)

######Blazor WebAssemblyApp:
![Blazor WebAssembly](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1pixmdxhog8qu2yv8ooj.png)

####Conclusion:
Each hosting models has their pros and cons. So, which model to choose is depends on your requirement. If you want an application that is supported by search engines, or has server-side support within the application then Blazor Server is your choice. And if you want your app to have offline capabilities and do not want to run on the server then Blazor WebAssembly.