Answers for "mvc invalidOperationException: Method 'InvokeAsync' of view component should be declared to return Task<t>"

C#
0

mvc invalidOperationException: Method 'InvokeAsync' of view component should be declared to return Task<t>

public class ExampleViewComponent : ViewComponent {
    public Task<IViewComponentResult> InvokeAsync() {
        ExampleModel model = new ExampleModel(2);

        // returns a finished task
        return Task.FromResult<IViewComponentResult>(View(model));
    }
}
Posted by: Guest on May-03-2021

C# Answers by Framework

Browse Popular Code Answers by Language