Aspnetcore: Question: Guidance on switch between server side and client side

Created on 9 Nov 2018  路  4Comments  路  Source: dotnet/aspnetcore

Was wondering if anyone could point me to docs and/or discussion regarding how best to setup a blazor project to more readily switch between server-side to client-side. For example in client side every call to the server might need to use HttpClient while on the server-side one could make direct calls to a class or EF to get data. I guess some form of data abstraction with a switch of some kind when client or server is detected? Any nudge in the right direction would be greatly appreciated. Thanks!

area-blazor

Most helpful comment

Solution designed by @Suchiman is very clever and perfect if you want to quickly switch to server mode to debug your code in VS. It is good because your code is exactly the same in client and server mode. In server mode you still use HTTPClient. This is of course suboptimal and if you have your data directly accessible from the web server you probably want to create some data abstraction layer to achieve the best possible performance in production.

All 4 comments

Solution designed by @Suchiman is very clever and perfect if you want to quickly switch to server mode to debug your code in VS. It is good because your code is exactly the same in client and server mode. In server mode you still use HTTPClient. This is of course suboptimal and if you have your data directly accessible from the web server you probably want to create some data abstraction layer to achieve the best possible performance in production.

services.AddServerSideBlazor() doesn't seems to work

Was this page helpful?
0 / 5 - 0 ratings

Related issues

groogiam picture groogiam  路  3Comments

UweKeim picture UweKeim  路  3Comments

BrennanConroy picture BrennanConroy  路  3Comments

Kevenvz picture Kevenvz  路  3Comments

guardrex picture guardrex  路  3Comments