csnewman / BlazorSignalR

SignalR Core C# client Blazor compatibility
MIT License
64 stars 21 forks source link

modifications for Server-Side Blazor #25

Closed AdmiralSnyder closed 5 years ago

AdmiralSnyder commented 5 years ago

added an option to set the IUrlHelper and a flag that implies the use of a HttpClientHandler instead of a WebAssymbly-specific WebAssemblyHttpMessageHandler which throws in SendAsync

see https://github.com/aspnet/AspNetCore/issues/10329

AdmiralSnyder commented 5 years ago

I think the modified json file update is not neccessary...

csnewman commented 5 years ago

What is the exact behaviour of this when running server side?

It is expected that all requests are forwarded to the browser at all times.

csnewman commented 5 years ago

This seems to overlap #12, I'd advise reading my open comments on that PR.

AdmiralSnyder commented 5 years ago

Hi, I did read your comments; #12 did multiple things and changed some conceptual methods, so I thought I'd create a very small PR that really doesn't change anything conceptually, and works now (isn't a WIP).

I am not sure what you mean with "exact behaviour when running server side". In the released version (against preview5), there were two errors that occurred, one because of the hard reference to the WebAssemblyUriHelper.Instance, the other because of the WebAssembly-specific HttpClientHandler. Both were fixed, so the errors do not occur anymore when running server side.

csnewman commented 5 years ago

I now remember the main issue with this approach.

Using HttpClientHandler is not the correct behaviour, as this causes the server to send some of the requests (while the browser will still handle websockets etc).

The proper solution is to replace WebAssemblyHttpMessageHandler with a custom handler that always forwards the requests to the browser.

The reason this is incorrect behaviour is that if you wanted the server to send the requests, you can check at runtime whether you are using server side blazor and use the standard WithUrl method instead of the WithUrlBlazor method.