I have a question about server side rendering of Blazor web app.

john yoon 20 Reputation points
2025-02-20T00:59:01.8933333+00:00

Hi, I am a GUI application developer.

Our company is using Blazor web app.

We are enthusiastic about using the attractive framework you provide and would like to ask some question.

Does the code block (@code) created in the .razor file work by creating as many threads as the number of clients connected to the server?

Blazor Training
Blazor Training
Blazor: A free and open-source web framework that enables developers to create web apps using C# and HTML being developed by Microsoft.Training: Instruction to develop new skills.
19 questions
0 comments No comments
{count} votes

Accepted answer
  1. Pradeep M 6,315 Reputation points Microsoft External Staff
    2025-02-20T04:07:14.6933333+00:00

    Hi john yoon

    Thank you for reaching out to Microsoft Q & A forum. 

    No, the @code block in a .razor file does not create a separate thread for each client. In Blazor Server, all client interactions are handled on the server through a SignalR connection, with each connection running in a single-threaded context. The framework manages thread safety using the ASP.NET Core synchronization context. For resource-intensive tasks, it's best to use Task.Run or async methods to improve performance and scalability.  

    If you have found the answer provided to be helpful, please click on the "Accept answer/Upvote" button so that it is useful for other members in the Microsoft Q&A community.  

    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.