Craig
Craig

Reputation: 585

Can you use a ViewComponent in a Blazor layout?

Just trying Blazor out for the first time. With the default Blazor template, I added a ViewComponent call to the MainLayout.cshtml:

@await Component.InvokeAsync("HeaderComponent")

IntelliSense shows await can only be used in an async method.

I tried the same in a Blazor view—same result. I use the component in an MVC app in the layout (via <vc:header-component />).

So I'm not sure if this is possible, or just a current Blazor or Visual Studio 2019 limitation.

Upvotes: 4

Views: 1247

Answers (1)

enet
enet

Reputation: 45596

No, you can't use ViewComponent in Blazor. And yes, this is a limitation, in the same sense you can't use ViewComponent in Angular.

Why do you need a partial view ? Is there any use case in Blazor that components cannot satisfy ?

Upvotes: 1

Related Questions