{"id":162,"date":"2020-06-30T05:00:32","date_gmt":"2020-06-30T03:00:32","guid":{"rendered":"https:\/\/archicode.be\/?p=162"},"modified":"2020-06-30T05:00:32","modified_gmt":"2020-06-30T03:00:32","slug":"blazor-server-side-or-web-assembly","status":"publish","type":"post","link":"https:\/\/archicode.be\/index.php\/2020\/06\/30\/blazor-server-side-or-web-assembly\/","title":{"rendered":"Blazor : server-side or Web assembly"},"content":{"rendered":"\n<p>Blazor is amazing.  This technology allows .net developers to leverage their hard-earned skills to develop amazing web applications without learning a new language or struggle with the big old javascript troll.  I was interviewing for a job when Blazor was first released as an experiment and the architect who was running the selection process told me that Blazor will never get a released version and that it will die out as quickly as Silverlight.  Well, Silverlight actually didn&#8217;t die out quickly but had quite a carreer.<\/p>\n\n\n\n<p>Some Blazor detractors keep saying that this technology is only a fancy version of Silverlight.  That is wrong.  Silverlight was xaml and c# running in the browser with the help of an installed plug-in, while Blazor is c# and html running in your browser without the help of any plug-in.<\/p>\n\n\n\n<p>As it is new, I know that not a lot of people are using it, but the community is very active behind it and when Telerik released <a rel=\"noreferrer noopener\" href=\"https:\/\/www.telerik.com\/blazor-ui\" target=\"_blank\"><strong>a full set of controls<\/strong><\/a> for Blazor, you know they won&#8217;t dedicate resources to something they wouldn&#8217;t trust and given the enthusiastic reponse Blazor received from the .net developer community, I can safely say it is here to stay.<\/p>\n\n\n\n<p>Now for those of you who don&#8217;t know what Blazor is, a word of explanation.  Blazor can be summarised as .net code running in the browser using two different technologies, server-side (using SignalR) and client-side (using Web Assembly).  If you are wondering what SignalR be, you can check it our <strong><a rel=\"noreferrer noopener\" href=\"https:\/\/docs.microsoft.com\/en-us\/aspnet\/signalr\/\" target=\"_blank\">here<\/a><\/strong>, there&#8217;s a lot of explanation and it&#8217;s a good starting point.<\/p>\n\n\n\n<p>I will try to explain in this post both sides of Blazor so it can help you all start up with this amazing technology.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">What is Blazor<\/h2>\n\n\n\n<p>Blazor was first introduced in NDC Oslo in 2017 by Steve Sanderson.  It was only a 10 minutes section in his presentation that lasted a full hour.  Now, what he presented wasn&#8217;t very big, but it was significant.  You can find the video <a rel=\"noreferrer noopener\" href=\"https:\/\/youtu.be\/MiLAE6HMr10?t=1902\" target=\"_blank\"><strong>here <\/strong><\/a>where he starts talking about .net in the browser, it&#8217;s inspiring to say the least.  The reaction of the audience was particularly pleasing.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Blazor Web Assembly<\/h2>\n\n\n\n<p>Web Assembly can be decribed as a kind of small virtual machine that allows your code to safely run in sandbox mode in your browser.  It is supported by <a rel=\"noreferrer noopener\" href=\"https:\/\/webassembly.org\/roadmap\/\" target=\"_blank\"><strong>Firefox, Chrome, Edge and Safari<\/strong><\/a>.  As it is natively supported you do not need a plug-in for it to run, which makes it much easier to deploy.<\/p>\n\n\n\n<p>The Blazor runtime is written using Mono, which is a reverse-engineered .net runtime that is the first that could run .net code in other platforms than Windows.  Mono is very interesting in that it is also what is behind Xamarin (that you use when you want to develop mobile applications for Android and IOS using .net)<\/p>\n\n\n\n<p>When running a Blazor Web Assembly application, dlls are first downloaded by your browser.  A small javascript bootstrapper code is executed to launch the Web Assembly runtime and the actual Blazor code is launched.  Blazor is not javascript code generated from c# code.  The Web Assembly runtime actually runs the c# code you wrote.<\/p>\n\n\n\n<p>The biggest advantage beside writing a rich web app using c# is that the application runs on your browser, so on your machine.  There are no page refresh needed and the only Client-Server Communications needed are the ones the app needs to fetch data and so on.  You do not need an internet connection when you application is downloaded for it to run.<\/p>\n\n\n\n<p>The main downside is that when you first open the application, it can take some time to open due to download, so you might want to check the size of your assemblies.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Blazor Server Side<\/h2>\n\n\n\n<p>Blazor Server-Side was the first version of Blazor to be released.  It leverages SignalR to make the application rich and interactive without needing a page refresh.  Your application is also bootstrapped using a small Javascript code that will launch the SignalR client.  This means that there will be a secure open channel between the client and the server that is needed for it to work. <\/p>\n\n\n\n<p>Now, there will be a few dlls needed for the application to run, but your entire application will not be downloaded.  Only the bits and pieces that the SignalR client will need to open a channel with the SignalR hub to make your application running.  So a great advantage of this is that the first run of the application will be fast but the actual launch of the application might be slow depending on your internet connection.  This means the Blazor Server-Side application cannot run without an internet connection.<\/p>\n\n\n\n<p>As Blazor Server-Side does not use Web Assembly, it can run on browsers that do not support the technology yet, and SignalR can run on quite old browsers as it uses either web socket or long polling to work, so you do not need to worry about how you call your server.  <\/p>\n\n\n\n<h2 class=\"wp-block-heading\">So which one do we want to use?<\/h2>\n\n\n\n<p>That will mainly depend on your application.  There are different scenarios we can think of but few will exclude one side or the other. <\/p>\n\n\n\n<p>I would recommend though as a rule of thumb that if your application is big  and you have a lot of client-server interactions, then you might want to use Blazor Server-Side.  On the other hand, if your application isn&#8217;t very heavy and downloads itself quite fast then Web Assembly is the way to go.<\/p>\n\n\n\n<p>A very big and important point is that you don&#8217;t code differently wether you use Server-Side or Web Assembly Blazor.  Only a few changes would be required and none would be needed in the code that runs in your pages.<\/p>\n\n\n\n<p>Happy Coding !<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Blazor is amazing.  But if you are wondering which of Web Assembly of Server-Side would suit your project, here&#8217;s an attempt to explain and help<\/p>\n","protected":false},"author":1,"featured_media":201,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_newsletter_tier_id":0,"footnotes":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false}}},"categories":[2],"tags":[],"class_list":["post-162","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-net"],"jetpack_publicize_connections":[],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","jetpack-related-posts":[{"id":92,"url":"https:\/\/archicode.be\/index.php\/2019\/06\/10\/how-to-blazorify-an-existing-mvc-app\/","url_meta":{"origin":162,"position":0},"title":"How to blazorify an existing mvc app","author":"Hakim","date":"June 10, 2019","format":false,"excerpt":"Blazor is awesome. \u00a0If you don't know what it is, you can check it out here\u00a0but to summarize, it's a framework that allows .net code to run in your browser using the power of Web Assembly. I've found a lot of tutorials using the official blazor templates but only hints\u2026","rel":"","context":"In &quot;.NET&quot;","block_context":{"text":".NET","link":"https:\/\/archicode.be\/index.php\/category\/net\/"},"img":{"alt_text":"migrate_solution_to_dotnet_core_3.gif","src":"\/wp-content\/uploads\/2019\/06\/migrate_solution_to_dotnet_core_3.gif","width":350,"height":200,"srcset":"\/wp-content\/uploads\/2019\/06\/migrate_solution_to_dotnet_core_3.gif 1x, \/wp-content\/uploads\/2019\/06\/migrate_solution_to_dotnet_core_3.gif 1.5x, \/wp-content\/uploads\/2019\/06\/migrate_solution_to_dotnet_core_3.gif 2x, \/wp-content\/uploads\/2019\/06\/migrate_solution_to_dotnet_core_3.gif 3x, \/wp-content\/uploads\/2019\/06\/migrate_solution_to_dotnet_core_3.gif 4x"},"classes":[]},{"id":163,"url":"https:\/\/archicode.be\/index.php\/2020\/07\/07\/blazor-convince-your-architect\/","url_meta":{"origin":162,"position":1},"title":"Blazor : convince your CTO (or whomever takes the technical decisions)","author":"Hakim","date":"July 7, 2020","format":false,"excerpt":"When there is something new on the market, we developers want to work with it. There might be several reasons for that, but not always the shortcut decision makers think we favour, which is wanting to try the new shiny thing. Most of the time, we want to work with\u2026","rel":"","context":"In &quot;.NET&quot;","block_context":{"text":".NET","link":"https:\/\/archicode.be\/index.php\/category\/net\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":115,"url":"https:\/\/archicode.be\/index.php\/2019\/10\/02\/how-to-blazor-components-basic\/","url_meta":{"origin":162,"position":2},"title":"How to : Blazor components (basic)","author":"Hakim","date":"October 2, 2019","format":false,"excerpt":"One essential aspect of Blazor are components. They are basically your Blazor code container. This is where you put the UI and the code needed for your UI to behave the way you want it to. You can dissociate the code from the UI but it's not mandatory. For small\u2026","rel":"","context":"In &quot;Uncategorised&quot;","block_context":{"text":"Uncategorised","link":"https:\/\/archicode.be\/index.php\/category\/uncategorised\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":370,"url":"https:\/\/archicode.be\/index.php\/2024\/05\/14\/understanding-blazor-component-parameters\/","url_meta":{"origin":162,"position":3},"title":"Understanding Blazor Component Parameters","author":"Hakim","date":"May 14, 2024","format":false,"excerpt":"Understanding Parameters Parameters in Blazor are used to pass data from a parent component to a child component. They are defined using public properties on a component and decorated with the [Parameter] attribute. Non-Complex Objects Non-complex objects such as integers, strings, and booleans can be passed as parameters. Here\u2019s an\u2026","rel":"","context":"In &quot;.NET&quot;","block_context":{"text":".NET","link":"https:\/\/archicode.be\/index.php\/category\/net\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":368,"url":"https:\/\/archicode.be\/index.php\/2024\/05\/12\/error-netsdk1082-in-maui-blazor-hybrid-app\/","url_meta":{"origin":162,"position":4},"title":"Error NETSDK1082 in Maui Blazor Hybrid App","author":"Hakim","date":"May 12, 2024","format":false,"excerpt":"There was no runtime pack for Microsoft.AspNetCore.App available for the specified RuntimeIdentifier 'android-x64' If you ever encountered this error in your Maui Blazor hybrid App, this is probably due to authentication.It took me a while to find it out (more than I care to admit) mainly because I had serial\u2026","rel":"","context":"In &quot;.NET&quot;","block_context":{"text":".NET","link":"https:\/\/archicode.be\/index.php\/category\/net\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":366,"url":"https:\/\/archicode.be\/index.php\/2024\/05\/11\/understanding-inject-in-blazor-components\/","url_meta":{"origin":162,"position":5},"title":"Understanding @inject in Blazor Components","author":"Hakim","date":"May 11, 2024","format":false,"excerpt":"Blazor, Microsoft\u2019s framework for building interactive client-side web UI with .NET, offers a robust solution for dependency injection (DI) in the form of the\u00a0@inject\u00a0directive. This powerful feature allows developers to inject services directly into their components, promoting a clean and modular architecture. What is Dependency Injection? Dependency Injection (DI) is\u2026","rel":"","context":"In &quot;.NET&quot;","block_context":{"text":".NET","link":"https:\/\/archicode.be\/index.php\/category\/net\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"_links":{"self":[{"href":"https:\/\/archicode.be\/index.php\/wp-json\/wp\/v2\/posts\/162","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/archicode.be\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/archicode.be\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/archicode.be\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/archicode.be\/index.php\/wp-json\/wp\/v2\/comments?post=162"}],"version-history":[{"count":0,"href":"https:\/\/archicode.be\/index.php\/wp-json\/wp\/v2\/posts\/162\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/archicode.be\/index.php\/wp-json\/"}],"wp:attachment":[{"href":"https:\/\/archicode.be\/index.php\/wp-json\/wp\/v2\/media?parent=162"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/archicode.be\/index.php\/wp-json\/wp\/v2\/categories?post=162"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/archicode.be\/index.php\/wp-json\/wp\/v2\/tags?post=162"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}