Today’s entry is all about Blazor WebAssembly which is different from Blazor Server. They use many of the same technologies, such as Razor Components. So, what’s the difference?
The Difference
Blazor Server does most of the work server-side and simply provides the user with the finished files (for example, HTML). Blazor WebAssembly does the work on the client-side. You can also install your web app as a "normal app" on your Windows machine complete with a desktop shortcut for easy access. With Blazor WebAssembly, everything is on the client side. So, we will need to talk to an API rather than directly to the database. If we talked directly to the database, everyone would have our database password since all of the code is downloaded to the client side. With an API, we can have better restrictions on data and logins that can define data access for each user. Blazor WebAssembly is more scalable as the work is done client-side. The downside is that loading times are longer because of all of the work being done client-side.
What It Looks Like
I have created a similar People and Places app like the one before. Although, I have changed it a bit this time just for fun. I know the forms are probably not best practices, but it was a challenge from the course I am working through.
(the button in Chrome to install the Blazor WebAssembly App)
(the Contact Form page I created for today’s code journal)
The Contact Form is actually two separate EditForms that
respond to one submit button. The web course I’m going through gave me somewhat
of a vague homework idea (maybe I was just overthinking or maybe I was just trying
to show off).
(And below this is more code from ContactForm.razor)
Ideas for Change
I would normally not do two forms with one submit button. That just seems super janky. I would make it one form with a larger model perhaps. In addition, if I did want two forms, I could organize this better by putting both forms into separate razor components that I then could bring into the main page file.
Up next, you should see some data access things on the blog. Or… maybe this app I made for the company I currently work for.
That's all for today, folks.