Quantcast
Channel: Active questions tagged blazor - Stack Overflow
Viewing all articles
Browse latest Browse all 4839

Why are Blazor lifecycle methods getting executed twice?

$
0
0

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 BlazorComponent does not exist anymore, so I move to ComponentBase. Not sure when did this change took place..

Now the rest of my code looks like this

public class LogoutModel : ComponentBase{    protected override async Task OnInitializedAsync()    {    }    protected override async Task OnParametersSetAsync()    {    }}

What i notice is that life cycle methods are executed in the following order

  1. OnInitializedAsync()
  2. OnParametersSetAsync()
  3. OnInitializedAsync()
  4. OnParametersSetAsync()

I am not really sure why is each method executed twice.

This is what my Blazor file looks like

@page  "/account/logout"@inherits LogoutModel<!DOCTYPE html><html><head><meta name="viewport" content="width=device-width" /><title></title></head><body>    Logout page</body></html>

Viewing all articles
Browse latest Browse all 4839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>