The working MVC version is
public class StatCategoriesController : BaseController
{
[HttpGet]
public async Task<ActionResult<IEnumerable<StatCategoryPreviewDto>>> GetStatCategoryPreview([FromQuery] GetStatCategoryPreviewQuery query)
{
return Ok(await Mediator.Send(query));
}
}
The RAZOR version is
public class CategoriesModel : PageModel
{
private IMediator _mediator;
protected IMediator Mediator =>
_mediator ?? (_mediator = HttpContext.RequestServices.GetService<IMediator>());
public async Task<IEnumerable<StatCategoryPreviewDto>> OnGet([FromQuery] GetStatCategoryPreviewQuery query)
{
return await Mediator.Send(query);
}
}
And the RAZOR verion doesn't return the JSON.. instead it returns..
nvalidOperationException: Unsupported handler method return type 'System.Threading.Tasks.Task1[System.Collections.Generic.IEnumerable
1[Srx.Application.StatCategories.Models.StatCategoryPreviewDto]]'.
Microsoft.AspNetCore.Mvc.RazorPages.Internal.ExecutorFactory.CreateHandlerMethod(HandlerMethodDescriptor handlerDescriptor)
Any idea ?