Blazor WebAssembly in .NET 8 - Why It Is Still Extremely Valuable
Вставка
- Опубліковано 11 вер 2024
- In .NET 8, we have a unified Blazor Web App project type that allows us to utilize components that run on Blazor Server, Blazor WebAssembly, or even auto, which progresses from Server to WebAssembly. We even have the opportunity to not use either interaction type if we want mostly static server-side rendered pages. However, you may have noticed that we still have a Blazor WebAssembly Standalone project type. If the new Blazor Web App project type is so great, why do we still have the old project type?
In this video, we are going to look at the Blazor WebAssembly Standalone project type, including what it does and why it is still valuable to have this project type. I highly recommend that you understand this project type and where it is valuable.
Full Training Courses: IAmTimCorey.com
Hosting Blazor WebAssembly is free in Azure. I am glad they kept the template. Loading time was improved also. Once the app starts, changing page is so quick. The overall experience is great.
Yep, the Azure Static Web App hosting is a great option.
Thanks Master, for sharing valuable insights to keep us ahead.
You are welcome.
Been using Blazor WASM in production for years. It’s great. It will be GOAT when it supports running ONNX models with GPU acceleration.
That seems more like a desktop feature rather than a WASM feature.
@@IAmTimCorey I did attempt ONNX with Maui Blazor, I dropped it in favor of Avalonia Blazor. This was due to lack of support for hardware acceleration on arm-Mac.
I think Maui can do ONNX with hardware acceleration on arm-Mac now, I haven’t verified this yet.
All that said, I still would like to be able to run ONNX models, with GPU acceleration, from the browser with Blazor.
Don’t underestimate small models, and don’t overlook, the massive performance boost, from hardware acceleration.
P.s. Thanks for the excellent content.
I really want WASM to succeed. I hate that blazor is used in most examples. Standalone is SO much better but a pain to figure out. Docs are all over the place in my opinion
Blazor is Microsoft's entry into WASM.
I'm not sure what you mean by standalone WASM. Do you mean WASM running just JavaScript instead of Blazor? Because Blazor is how you run C# code on WASM. And Blazor makes it so easy to do what you need to do.
@@IAmTimCorey Yes exactly! I've tried to play around with WASM. As fair as I know, it's how you run c# code in your browser. I've managed to run it within a django / react environment. My road to this environment was very bumpy. I've made a couple of emulators and I thought c# would be a bit faster. When reasearching this I found blazor. Blazor standalone, some wasm version without blazor at all, and that was about it I believe. That last one was/is interesting to me because I didnt need the blazor framework at all. (this was before the wasm update from a week back or so)
emscripten is what I ment
Skipping over the Authentication for Blazor WASM. Good move, Tim. It's a freaking nightmare.
If you're using cookie auth, it's not too bad. Every other method, though... yeah... Not great. Especially if you have to integrate your authentication with some kind of third-party software that doesn't abide by OAuth, Google, Facebook, or Microsoft Identity Platform standards.
I assess the difficulty level to be equivalent to angular/react if you’re doing JWT
@@EekChocolate I had to turn to IdentityServer, and getting that to play nice with SSL + CORS via SignalR... I got there, eventually, but yeesh!
I'm working on some demos for authentication with WASM. Fun times.
Actually everyone on YT is doing that... there is small to none portion of videos about auth in Blazor. In most cases they just show some dead simple example with cookies usage and thats all. When you actually jump into Blazor and you start working on big project, you will hit the wall quite fast.
Looking for more videos on this. You mentioned local storage, I was wondering if you could leverage SQLite as one of the videos
Thanks
For the browser, I typically just use LocalStorage instead of trying to make SQLite work. I find it easier and less problematic. I'll be doing a video or two on LocalStorage and how to use it.
thank you so much for this video , it would be great if you come back to make advanced lessons about blazor
Thanks for the suggestion. Please add it to the list on the suggestion site so others can vote on it as well: suggestions.iamtimcorey.com/
Hi Tim, Are you going to make a Login and Authorization video for WinUI in the real world soon? I think it is very important especially for NavigationView control which is used by everyone. There is no content creator supported by Microsoft for WinUI. I don't understand why this field is empty. There are many people in Blazor, MAUI or Azure but WinUI seems to be left empty. Thanks.
The reason why it is fairly empty is because WinUI isn't even well supported by Microsoft. They recently recommended people use WinForms or WPF for desktop development. WinUI is rather restricted in what it can do, which limits its usage in corporate environments.
@@IAmTimCorey Actually there was a video just posted on the Windows Dev channel called "Building a Modern, Native Application for Windows: Which UI Framework Should You Choose?" where they said Microsoft recommends using WPF or WinUI. So they keep saying publically that their focus is on WinUI and WPF.
thanks tim .. i think wasm will be the new generation for web app that run over client side and i think other framework like angular and react will try to do it and i think security will be good in the future wasm is a sand box not like other framework like angular
WASM is a great option for hitting that middle ground between desktop app and website.
Is Blazor on the way of making MVC and MVVM obsolete? Is there a point for someone who is starting with .NET and Blazor to learn MVC or MVVM?
MVC and MVVM are just design patterns. I'm assuming you are referring to ASP.NET Core MVC, which is a web project type named after the pattern it uses. There is definitely a benefit to learning MVC and the other web project types, since options are good. Not every situation will require the same solution.
some years ago, when .Net 6 was recently released, i tried Blazor WASM but i had some problems with the browser cache cause when the app was already deployed and needed to makes some changes and then publish again, i couldnt see those changes applied until I completely cleared the whole history and data from the website stored in the browser, is this already solved in recent versions of . NET?
This isn't a bug, it is a feature and it is a WASM feature, not a Blazor-specific feature. What is happening is that WASM applications are...applications. That means that they are on the larger side typically. That means the initial page load can be a lot sometimes. Once the application is loaded, though, it uses the browser's cache to make subsequent page loads extremely fast. Beyond this, it also allows the application to work offline if you so choose. So, with that in mind, what would happen if you made a change to the application? Well, the entire application would need to be re-downloaded. That means that the user would have to wait until the site re-downloaded before they could use their app. That's not a great experience. That's why part of the WASM standard is that the service worker loads the cached website. Then, it checks for updates on the server. If it finds the updates (and if the app is online in the first place), it downloads the changes in the background. It then marks the app as ready to update. The next time the user launches the app, they will get the new version. It won't do it after the download because the user might be in the middle of something.
So, this is the standard way WASM works. When you are debugging a Blazor WASM app in Visual Studio, however, you see the changes right away. That's because there is a special development service worker that is used that does not cache the application.
So if I want my Blazor WebAssembly project to access and API with an API key. I should build another API that does that interaction and also stores all the sensitive information like the API key?
If you need to have sensitive information then yes, wrap that in an API. So yes, your API might call another API. That's ok.
@@IAmTimCorey Then restrict the access to the "middleware" in some way? By IP address or some other server setting, right? So that only the blazor webassembly site can use it.
what's the Best way to Manage user session in Blazor WASM Standalone project? is it possible to use cookies?
It is possible to use cookies or SessionStorage. Either works. You hear horror stories about using SessionStorage/LocalStorage, but these are way overblown. The technical attack surface is slightly bigger, but we are talking about 0.01% vs 0.02%, if that.
When using the PWA option and installing the app on the client, what happend if there is a new version/update of that appilcation. Will the app on the client get updated automatically or is the user forced to reintall the app?
When a new version is out (basically, an update to the website), the app will load the old version one more time. In the background, it will download the changes to the site. Then, when the user next uses the app, they will use the new version. That way they can continue to use the older version until the new one is downloaded rather than having the app go down until the changes are downloaded.
@@IAmTimCorey Thanks for your comprehensive answer.
@@IAmTimCorey, Blazor WASM PWA updated? I built an application sometimes ago, Blazor WASM PWA, after publishing changes, it never get downloaded no matter how many times I restart the application, I had to pull off the app and made it just Blazor WASM without PWA. It was an annoying effort.
hi, Please make a video to design and implement a dashboard using SignalR and blazor in .net 8
Thanks for the suggestion. Please add it to the list on the suggestion site so others can vote on it as well: suggestions.iamtimcorey.com/
Valueable? But based on job post it has low demand as of now.. some SME are tired of Microsoft fast changing technology but with similar outcome.. Although I love this new Blazor thing, however it cannot give me additional money to provide food to table
Exactly... What's wrong with mvc core coupled with signalr?
@@victorene3608 It's not a SPA (and no PWA). Totally different paradigm.
That's right, I'm learning Blazor and have been trying to build up a medium sized project as my portfolio, but it's so hard to find work. I love Blazor, but I still have to put food on the table.
Couple things here. First, you have to remember that companies don't start working on their enterprise applications overnight. The vast majority of companies have enterprise applications that are five years old or older. That's just the nature of enterprise applications. That means that they were built before Blazor was a thing. That means that a very few companies even had the option of using Blazor for their enterprise application. Secondary systems, sure, but their primary systems are almost always older technologies that have not been upgraded. That means you will see a LOT more MVC or even WebForms. That's also why you still see so many jobs asking for .NET Framework developers.
Second, remember that Blazor is a project type on top of the ASP.NET Core web framework. That means that jobs that are asking for ASP.NET Core developers could be using Blazor (or could be considering it). Basically, any job that uses .NET (not .NET Framework) could be using Blazor or is considering it. This also means that even if you aren't using Blazor, you are using the skills that you want to grow if you want to get into Blazor.
blazor , vue ,react ,angular or svelte for newcomer asp.net core developer?
Since you are new, I would highly recommend you start with Blazor since it will keep you learning C# and allow you to go deeper in the language rather than spreading you thin in multiple languages and frameworks.
you mean i start learning blazor,and after that i should learn js framework(vue,react,or angular)? or u mean blazor will be enough?