Search code examples
asp.net-coreasp.net-core-viewcomponent

Component use only InvokeAsync method. There isn't synchronous pure Invoke method


It very odd for me, Razor give only synchronous Invoke for View Components in particular project.In other project I have access to pure Invoke method. I assume the difference comes from dependencies.


Solution

  • Component.Invoke is removed for the newest versions of .net Core And parameter collection is replaced by anonymous object. We should use view components that way :

    @await Component.InvokeAsync("ComponentName", new {param=value })