C
C#2mo ago
Xymanek

Blazor WASM + prerender - handling forms on client & server

I'm trying out Blazor WASM + prerender and I noticed that form submission is handled by either server or WASM C#, depending on whether the latter is loaded (yet). Given that some logic must run on the server (e.g. DB access), what's the standard approach to "marshalling" the invocation to the server? I definitely prefer to have WASM handle the initial submission for interactive validation, status display, etc
6 Replies
Salman
Salman2mo ago
I think I don't understand the question properly but about this :
I definitely prefer to have WASM handle the initial submission for interactive validation, status display, etc
Yes you can do that in WASM by using built in blazor validation...and submit the form only if the inputs are valid according to your validation rules i.e your View Model . And you submit the data to the server through API calls
Xymanek
XymanekOP2mo ago
Ok, ignore the last part for a sec.
And you submit the data to the server through API calls
But what happens if the server is already handling the form submission? i.e. it was not intercepted by WASM
Salman
Salman2mo ago
tbh Idk. I would just not display the form if WASM isn't loaded yet and would show some loading spinners or skeletons
Xymanek
XymanekOP2mo ago
I mean for some simple forms... why not? Allows the site to be usable faster
Salman
Salman2mo ago
so far I've not used WASM myself and only used server components so I dont know how longer it takes to load. But in the demos of the ongoing conference, it loaded pretty quickly , but again I've no idea how long it usually takes btw there's a dedicated blazor channel in Dotnet Evolution you can ask it there as well : https://discord.com/channels/732297728826277939/732297874062311424
Xymanek
XymanekOP2mo ago
Yeah I know but thatnks for the reminder
Want results from more Discord servers?
Add your server