1

I want to use Blazor Component in my ASP.NET MVC App. So, I follow article like this one : https://fizzylogic.nl/2019/08/18/integrating-blazor-in-an-existing-asp-net-core-application/

The behavior is quite strange, because I have no errors in my console, and my breakpoint put in OnInitializedAsync is fired, but I never reach my breakpoint in OnAfterRenderAsync...

I put breakpoints in BuildRenderTree & OnParametersSet, all of them are fired. My parameters are correctly set, and the ShouldRender method returns true. I also add a StateHasChanged() in OnInitializedAsync, but my component is still not rendering.

For testing, I replace all my component code by and still nothing render...

2 Answers 2

2

Use the new way of rendering components in mvc razor pages:

<component type="typeof(Namespace.Pages.Component)" render-mode="ServerPrerendered" param-AnyParameter="parameterValue" />
Sign up to request clarification or add additional context in comments.

5 Comments

Thanks for this answer. In fact, I also already try this, without success...
Can you share your other setup? I have done the same process in my project and it works fine.
I've done the same myself, what I don't understand is why all my component's method are called except AfterRenderAsync ...
That's odd, have you tried this in a blank default new project and if possible share that project on github?
Figure it out that I was loading blazor script in head section instead of bottom of body. After moving it to bottom of body, my component render !
2

I discover that loading blazor server client javascript file MUST be done in the bottom of the file. I was loading it in the of my HTML, which makes my component not rendering.

Moving it to my Scripts section of my razor view make it works !

1 Comment

Thank you so much, was starting to pull my hair out a bit haha

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.