Server-side Blazor is a web framework from Microsoft to create single page apps running on the server. Changes to the DOM and events in the browser are communicated via a SignalR connection. Blazor is built on ASP.NET Core.
Questions tagged [blazor-server-side]
4351 questions
76
votes
6 answers
Why are Blazor lifecycle methods getting executed twice?
So with a release of asp.net core 3.0 and blazor 1.0 I started doing some actual work with blazor. When splitting Blazor component code into code behind I am using the following
public class LogoutModel : BlazorComponent
{
}
Unfortunately…

mko
- 6,638
- 12
- 67
- 118
71
votes
14 answers
Get Current User in a Blazor component
I'm starting a new site with Blazor and Windows Authentication and need to identify the current user viewing the page/component.
For a Razor Page, the current user name can be accessed with Context.User.Identity.Name, but that doesn't seem to work…

Wes H
- 4,186
- 2
- 13
- 24
66
votes
1 answer
StateHasChanged() vs InvokeAsync(StateHasChanged) in Blazor
I know that calling the StateHasChanged() method notifies the component that the state has changed and so it should re-render.
However, I also sometimes see things like await InvokeAsync(StateHasChanged) or await InvokeAsync(() => StateHasChanged())…

Arad Alvand
- 8,607
- 10
- 51
- 71
59
votes
5 answers
How to turn on CircuitOptions.DetailedErrors?
I'm getting this message in the console when running a server-side Blazor app:
Error: There was an unhandled exception on the current circuit, so
this circuit will be terminated. For more details turn on detailed
exceptions in…

tomRedox
- 28,092
- 24
- 117
- 154
53
votes
9 answers
Is there any hot reload for blazor server-side?
I have just one, quick question.
Is there way to hot reload a blazor app? At least, .razor files?
Now I'm hosting my app on local IIS (not IIS express).
I was looking through internet, but i didn't found anything helpful.
Thank you all for anwsering…

cebilon123
- 551
- 1
- 4
- 7
51
votes
9 answers
How to store session data in server-side blazor
In a server-side Blazor app I'd like to store some state that is retained between page navigation. How can I do it?
Regular ASP.NET Core session state does not seem to be available as most likely the following note in Session and app sate in ASP.NET…

Codo
- 75,595
- 17
- 168
- 206
47
votes
7 answers
Blazor component : refresh parent when model is updated from child component
I'm using Server-side Blazor components in ASP.NET Core 3 preview 4.
I have a parent component, and child components, using the same shared model, like this :
Model :
public class CountModel
{
public int Count { get; set; }
public void…

glacasa
- 1,770
- 2
- 16
- 32
46
votes
6 answers
Blazor link - disable href if there's an onclick method
In Blazor I have an element that has both a href and an onclick method:
Test
onclick calls this method:
private bool ChangePage(object objectToDisplay)
{
_currentObject =…

tomRedox
- 28,092
- 24
- 117
- 154
42
votes
2 answers
Execute async method on button click in blazor
I created a "Razor Components" project. I am trying to execute an asynchronous method when pressing a button, but could not figure out the syntax yet.
This is my Index.razor:
@page "/"
@inject GenericRepository PersonRepository
@foreach…

ˈvɔlə
- 9,204
- 10
- 63
- 89
41
votes
1 answer
How to inject in blazor code behind .razor.cs file? IJSRuntime for example
With a normal single page razor component in Blazor. I can inject IJSRuntime like this at the top of the page:
@inject IJSRuntime JSRuntime
If I create a code behind .razor.cs file for the component, how do I inject something like IJSRuntime into…

Kyle
- 32,731
- 39
- 134
- 184
39
votes
12 answers
Blazor - cannot convert from 'method group' to 'EventCallback'
I have a parent component and a child component with an event callback where I want it to pass back a type of T.
The issue I'm having is that I have an error about converting
MethodGroup to EventCallback.
If I convert this to using an Action then…

scottdavidwalker
- 1,118
- 1
- 12
- 30
38
votes
4 answers
InputText requires a value for the 'ValueExpression' parameter
I want to be able to render a form with Blazor (Server Side Rendering) but I am not getting the right syntax.
…

kolek
- 557
- 1
- 6
- 13
36
votes
4 answers
How to fix 'The current thread is not associated with the renderer's synchronization context'?
I am trying to change a string, being used for a title, in my blazor-server-side application. But I am having trouble getting the UI to update.
I tried using StateHasChanged(), but that didn't work so I looked around and found that on the…

DalTron
- 939
- 3
- 9
- 22
33
votes
2 answers
Blazor Server side vs Blazor WebAssembly Hosted
I am new to Blazor and am trying to understand the differences between different hosting models.
From what I read I understand Blazor Server side and Blazor WebAssembly Hosted have server side code, both use Signal R to communicate with the…

Newbie
- 563
- 1
- 5
- 16
33
votes
3 answers
Require authorization on ALL Blazor pages
I am playing with Blazor and created a web app that is server hosted. I have to put an authorize line on top of the page like this @attribute [Authorize] to ensure the user is logged in.
It seems like I have to add this line to each page…

Franky
- 1,262
- 2
- 16
- 31