0

I am making a website using Blazor/razor where the login page has a different layout than my default layout. I know I have to use the @layout tag at the top of the page to specify that I am using a different layout, but the problem is that when the page opens, it seems as if the default layout is used for a split second before it changes to use my specified layout. Any suggestions as to how to stop that from happening?

1
  • 1
    Please provide enough code so others can better understand or reproduce the problem. Commented Nov 6, 2021 at 9:34

1 Answer 1

0

The issue was the call for await base.OnInitializedAsync() was being done in the incorrect order. In my MainLayout.razor file, there is an OnInitializedAsync method containing the aforementioned await call. I also have some logic checking if a user has been authenticated to use the website (logged in), to be redirected to the loggin page if not. By making sure that the await base.OnInitializedAsync() call is after that logic, the page stopped rendering the incorrect layout before loading the "overridden" layout. From what I can gather, this is because the await call contains the base keyword which has something to do with layouts, so having this call before my redirection logic was initializing the page and rendering the default layout of the page before any logic was done.

Sign up to request clarification or add additional context in comments.

3 Comments

In general, await base.OnInitializedAsync(); should just be deleted.
Got it. Is that just a place holder for a proper implementation of the method then?
Yes. Intellisense will always add that when you override a method. It's your choice what to do with it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.