How to Use Blazor Components in ASP.NET Core MVC?

  Рет қаралды 6,687

Claudio Bernasconi

Claudio Bernasconi

Күн бұрын

Пікірлер: 31
@timmy334
@timmy334 10 ай бұрын
This video provides the exact answers I needed! Thank you!
@ClaudioBernasconi
@ClaudioBernasconi 10 ай бұрын
Glad it was helpful!
@maxalbrecht9913
@maxalbrecht9913 11 ай бұрын
Hi, I am up to 3:30, but when I click the "Generate" button, the number does not change
@ClaudioBernasconi
@ClaudioBernasconi 11 ай бұрын
That is not okay. However, it's hard to help you like that, I'm sorry. I hope you'll find a solution.
@ItsBabywise
@ItsBabywise 9 ай бұрын
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
@grzegorzwisniewski8394
@grzegorzwisniewski8394 5 ай бұрын
@@ItsBabywise hi, I have the same problem and unfortunetly your solution not work for me. Do you have any other suggestions?
@nogginbox
@nogginbox 4 ай бұрын
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?
@ClaudioBernasconi
@ClaudioBernasconi 4 ай бұрын
It's a great question. I don't know it from the top of my head. I hope you were able to find a solution. Let us know if you did. Thank you.
@nezqwe4818
@nezqwe4818 11 ай бұрын
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
@ClaudioBernasconi
@ClaudioBernasconi 11 ай бұрын
It depends on how you initialize the value. OnInitialiezed or OnInizializedAsync are good locations. Hard to tell your issue without seeing your code.
@nezqwe4818
@nezqwe4818 11 ай бұрын
@@ClaudioBernasconi Ah, figured it out. It was prerender. I need to change render mode to render-mode="WebAssembly"
@thibaultdolley734
@thibaultdolley734 7 ай бұрын
Thank you for providing the github repository
@ClaudioBernasconi
@ClaudioBernasconi 7 ай бұрын
I hope it helps. 😉
@robdevoer1
@robdevoer1 5 ай бұрын
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 { }
@ClaudioBernasconi
@ClaudioBernasconi 5 ай бұрын
@@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?
@ailhad
@ailhad 4 ай бұрын
this just saved my life
@ClaudioBernasconi
@ClaudioBernasconi 4 ай бұрын
@@ailhad glad you're doing well! 🙏😉
@THEArenaVD
@THEArenaVD 9 ай бұрын
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?
@ClaudioBernasconi
@ClaudioBernasconi 9 ай бұрын
What is the error?
@leonardohidrovo4729
@leonardohidrovo4729 Жыл бұрын
Using Sessions in a MVC core application, how to use the user session values in a Blazor component inside MVC view?
@ClaudioBernasconi
@ClaudioBernasconi Жыл бұрын
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.
@leonardohidrovo4729
@leonardohidrovo4729 Жыл бұрын
@@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
@ndasss9563
@ndasss9563 Жыл бұрын
Does this work on .net 7 as well ? Sry im new..
@ClaudioBernasconi
@ClaudioBernasconi Жыл бұрын
Thanks for your question, and welcome. Yes, it should also work on .NET 7.
@10Totti
@10Totti Жыл бұрын
Thanks, but it wouldn't be easier to use Blazor Custom Elements
@ClaudioBernasconi
@ClaudioBernasconi Жыл бұрын
I haven't explored custom elements in Blazor yet.
Blazor Localization in .NET 8 & Blazor Server
13:58
Claudio Bernasconi
Рет қаралды 10 М.
ASP.Net MVC Vs Blazor: The Ultimate Showdown - Who Will Reign Supreme?
19:39
The evil clown plays a prank on the angel
00:39
超人夫妇
Рет қаралды 53 МЛН
Cheerleader Transformation That Left Everyone Speechless! #shorts
00:27
Fabiosa Best Lifehacks
Рет қаралды 16 МЛН
How to treat Acne💉
00:31
ISSEI / いっせい
Рет қаралды 108 МЛН
Global exception handling in asp net core mvc
9:08
kudvenkat
Рет қаралды 110 М.
Adding Blazor Components to MVC - It's easier than you think.
12:32
DotNetMastery
Рет қаралды 3,8 М.
Brutally honest advice for new .NET Web Developers
7:19
Ed Andersen
Рет қаралды 296 М.
Razor Pages vs MVC vs Blazor
6:30
CodeGanesh
Рет қаралды 5 М.
Implementing JWT Authentication in ASP.NET Core
23:51
Nick Chapsas
Рет қаралды 47 М.
The evil clown plays a prank on the angel
00:39
超人夫妇
Рет қаралды 53 МЛН