Thanks for this great example! One improvement is to not add the reference to the blazor script in your layout page but to include that into the scripts section of the page(s) that call the blazor component. This way only the pages that require blazor will use the script. @section Scripts { }
@@robdevoer1 interesting. Have you tested if that results in multiple downloads when navigating to the page multiple times? Or does the browser cache the file in your case?
This shows me almost exactly what I want to do. Is there a way to route some pages to a Blazor WASM page component and the rest to existing MVC controllers?
Hi, I tried doing this with but when it hit the page. the generated value got ran twice by itself. For example, I hit the page the shown var was 22 then a few miliseconds it changed to 67. How do I prevent it from running again? I'm on .net 8.0.1
Hey im trying to pass in a complex Object List in my razor component and when running my application I get Blazor server error usung chrome. Would you habe any idea as to why this is occurring?
Did you ever fix this issue? This seems to be my problem with every tutorial EDIT: The reason you get this issue is because your _Imports.razor does not yet exist if you're following along at 3:32... if u look closely, _Imports.razor appears on the right side in the video but its not talked about until afterwards which might be where your confusion comes from, once you add this file it will update
Great question. I'm not familiar with how Sessions work in MVC. However, that shouldn't be an issue. The concept is simple. You have to provide every information you want to use inside a Blazor component as an argument. There are more advanced concepts but I would keep it simple and provide the information from the Session as an argument (parameter) to the Blazor component. Say you want to use the username, you add a parameter using the [Parameter] attribute on the Blazor component and then provide it when you use the component.
@@ClaudioBernasconi thanks for the response. In my case I would like to use some existing mvc services (scope implementation) that uses IhttpcontextAccesor to get de user session values and retrieve information from database. However I saw in the Microsoft documentation that is not recommend to use the HttpContext in blazor server