Search code examples
signalrwebassemblyblazorasp.net-core-signalrblazor-server-side

Which hosting model for Blazor application with dynamic UI talking to remote SQL Server?


If you wanted to port a "legacy" ASP.NET application that fetches data from a remote SQL Server instance by way of System.Data.SqlCient methods running in the code-behind of a HttpHandler (the data returned from the server gets jsonified and injected into the UI widgets, e.g. kendoUI), what is the appropriate Blazor hosting model?

  Blazor server-side  
  Blazor ASP.NET Core Hosted 
  Blazor client-side

Judging from the description that Visual Studio 2019 Preview offers of Blazor (server-side):

... This template can be used for web applications with rich dynamic user interfaces...

Blazor (server-side) seems the right choice.

But does SignalR give you a way to use Blazor (ASP.NET Core hosted) instead? Visual Studio says this hosting model "runs on WebAssembly and is hosted on an ASP.NET Core server" but I'm not sure what that means, exactly. Where is the WebAssembly running? Client? Server? Both places?

Can SignalR together with the Blazor (ASP.NET Core hosted) model be used to create a pipeline from the server-side WebAssembly to the client-side WebAssembly that obviates the need for the HttpHandler?

The description of SignalR here on StackOverflow suggests that it is almost magical in its capabilities:

ASP.NET SignalR ... makes it incredibly simple to add real-time web functionality to your applications...to have your server-side code push content to the connected clients as it happens, in real-time.
[my emphasis]

Ignoring the "as it happens, in real-time" phrase for a moment as being unrelated to the question, can the same pipeline be used to push any (smallish) data-set to the "connected client"? This is a legacy "intranet" application that I'm asking about, BTW, with only a few dozen users.


Solution

  • that fetches data from a remote SQL Server instance by way of System.Data.SqlCient

    That part should defintely run on the server. There is no SqlClient in the Browser.
    Running Blazor server-side ought to work. You should not have to deal with SignalR directly.

    running in the code-behind of a HttpHandler (the data returned from the server gets jsonified and ...

    That sounds like it would fit to the Hosted model: an API server exposing endpoints to the client. It would leave you with the best architecture, but it may be more work.