Mvc: ViewComponent returns objects(?)

Created on 24 May 2016  路  4Comments  路  Source: aspnet/Mvc

Hi, i successfully migrate my project from RC1 to RC2 but i have a issue with Components. I change
@Component.Invoke("ContactField")
to
@Component.InvokeAsync("ContactField").
But now in view i have text -> System.Threading.Tasks.Task`1[Microsoft.AspNetCore.Html.IHtmlContent]

What can i do with this issue?

Most helpful comment

Im not sure if you can await in a razorview, but if not use @Component.InvokeAsync("ContactField").Result to get the underlaying Result of the Task.

All 4 comments

Im not sure if you can await in a razorview, but if not use @Component.InvokeAsync("ContactField").Result to get the underlaying Result of the Task.

Thanks :)

Announcement for this change here: https://github.com/aspnet/Announcements/issues/145

You just need to await the result:

@await Component.InvokeAsync("ContactField")

Was this page helpful?
0 / 5 - 0 ratings