Slicc
Slicc

Reputation: 3435

Optionally run blazor server side

As I understand it, razor components runs entirely server side, each method call results in a signalr request to the server and the method called is executed on the server.

In blazor however, the DLLs and the runtime are shipped down to the client and methods are executed in the browser. To make a server call I now need to create an API and make standard API requests.

What I would like to know is, is it possible in blazor to generally execute everything client side as per normal, but for some methods to be executed server side? So a kind of hybrid between blazor and razor components? So doing away with the need for an API?

Upvotes: 1

Views: 428

Answers (1)

enet
enet

Reputation: 45626

Razor Components is an obsolete term referring to the Component framework with which you could create either server-side Blazor applications, or client-side applications. It was unsuccessful short-lived term. Currently, the name Blazor is used to refer to the Component framework with which you can create either server-side Blazor applications, or client-side applications. This is actually how we named both kinds of application from the very beginning.

Client-side applications are executed on the browser via WebAssembly. Server-side Blazor application run entirely on the server, and communicate with the browser via SingnalR.

Front-end Blazor applications, generally speaking, require you to create a Web API on the server, and employ Ajax (HttpClient) to communicate with the server.

What model of execution you choose depend on the requirements of your application. Server-Side Blazor application are best suited for Intranet enterprise applications, while client-side Blazor applications are best suited to run across in the public Internet. Each mode of execution have its advantages and disadvantages.

Hybrid applications, I guess, is possible, but is it, generally speaking, recommended ? When ? How ? It is too early to know... The framework is after all under construction, and patterns of appropriate coding is yet to be formulated in the course of time. But surely you can create a client-side Blazor app which communicate with Web API which exposes SignalR endpoints.(You wanted to know this, right?)

Hope this helps...

Upvotes: 2

Related Questions