Answered by:
Adding Signal r to Razor Pages

Question
-
User-639631676 posted
Hello
I believe everything is all automatically set up for signal r in Blazor Server Side ?
I want to set up the same generic signal r for Razor Pages, so that "anything" that needs updated on the client after say a button click is done via Signal r, do I need a hub or is that just to call specific methods ?
I am a hobbyist programmer and like to keep things practical and simple, and if Blazor is automatically set up for Signal r, why is not Razor Pages as well, coming from Webforms and .net 4.5 with Core there seems to be so much boiler plate code you need to add, surely Microsoft could have made all this much easier
Thanks
Gary
Friday, July 10, 2020 2:18 PM
Answers
-
User475983607 posted
My understanding is that out of the box a new Blazor Server Side App is all set up for Signal R, and this will not do full page refresh's but just send the the client the differences to be updated on the client, therefore no page refresh flicker of course
I want this same feature on Razor Pages, is it possible or not please ?
I think you misunderstand. Razor Pages with SignalR are the building blocks for Server Side Blazor. Implement a Blazor solution if you want everything reading to go. If you want a custom solution then you can look to Razor Pages with SignalR. When you install SignalR it provides all the tools needed for a persistent connection but determining what events to response to and what to update on the page is left up to the programmer.
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Friday, July 10, 2020 3:25 PM
All replies
-
User348806598 posted
Hi,
Here is the detailed explanation for the same-
Friday, July 10, 2020 2:26 PM -
User-639631676 posted
Thanks Asteranup for your link
I have looked at the link and it is specially for a chat app, all I want is a basic setup of Signal R, so that it will automatically update any page by not refreshing the full page, I do not need the specific set up for a chat app, can you help please ?
Thanks
Gary
Friday, July 10, 2020 2:35 PM -
User-474980206 posted
Signal/r is a communication protocol over websockets. On the browser side it’s only available from JavaScript. So you need to write a JavaScript application to use it. Razor pages is for the server to produce html. So for razor pages to use signal/r you need to write JavaScript client code to use it.
blazor server is a JavaScript client application that calls a server render engine.
Friday, July 10, 2020 2:37 PM -
User475983607 posted
I want to set up the same generic signal r for Razor Pages, so that "anything" that needs updated on the client after say a button click is done via Signal r, do I need a hub or is that just to call specific methods ?Install and configure SignalR according to the openly published docs. This info was provided in your similar post. Are you having a problem after setting up SingalR and running the sample?
https://docs.microsoft.com/en-us/aspnet/core/signalr/introduction?view=aspnetcore-3.1
I am a hobbyist programmer and like to keep things practical and simple, and if Blazor is automatically set up for Signal r, why is not Razor Pages as well, coming from Webforms and .net 4.5 with Core there seems to be so much boiler plate code you need to add, surely Microsoft could have made all this much easierWhat problem are you having or are trying to solve?
Razor pages is a server side technology. SignalR is a persistent real-time connection between a browser and a web server. This allows the browser application to respond to events on the web server. Generally, program requirements drive what technology is used.
Friday, July 10, 2020 2:38 PM -
User-639631676 posted
Hello bruce
My understanding is that out of the box a new Blazor Server Side App is all set up for Signal R, and this will not do full page refresh's but just send the the client the differences to be updated on the client, therefore no page refresh flicker of course
I want this same feature on Razor Pages, is it possible or not please ?
Thanks
Gary
Friday, July 10, 2020 3:05 PM -
User475983607 posted
My understanding is that out of the box a new Blazor Server Side App is all set up for Signal R, and this will not do full page refresh's but just send the the client the differences to be updated on the client, therefore no page refresh flicker of course
I want this same feature on Razor Pages, is it possible or not please ?
I think you misunderstand. Razor Pages with SignalR are the building blocks for Server Side Blazor. Implement a Blazor solution if you want everything reading to go. If you want a custom solution then you can look to Razor Pages with SignalR. When you install SignalR it provides all the tools needed for a persistent connection but determining what events to response to and what to update on the page is left up to the programmer.
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Friday, July 10, 2020 3:25 PM -
User-639631676 posted
Hello mgebhard
Thanks for you answer yes that makes it clear
So to make it easy all is setup on Blazor for you, but on Razor Pages you need to set things up, I would have thought it would have all been set up on Razor Pages as well, as it saves allot of messing around, again I am a hobbyist programmer from webforms so hope you can see where I am coming from regarding practicality and simplicity
Thanks
Gary
Friday, July 10, 2020 3:35 PM