title: Moving MediatR from a MVC project to Razor Pages. Cannot get basic syntax to work
body: <p>The working MVC version is</p>
  
  <pre><code> public class StatCategoriesController : BaseController
  {
      [HttpGet]
      public async Task&lt;ActionResult&lt;IEnumerable&lt;StatCategoryPreviewDto&gt;&gt;&gt; GetStatCategoryPreview([FromQuery] GetStatCategoryPreviewQuery query)
      {
          return Ok(await Mediator.Send(query));
      }    
  }
  </code></pre>
  
  <p>The RAZOR version is</p>
  
  <pre><code>  public class CategoriesModel : PageModel
  {
      private IMediator _mediator;
  
      protected IMediator Mediator =&gt;
          _mediator ?? (_mediator = HttpContext.RequestServices.GetService&lt;IMediator&gt;());
  
      public async Task&lt;IEnumerable&lt;StatCategoryPreviewDto&gt;&gt; OnGet([FromQuery] GetStatCategoryPreviewQuery query)
      {
          return await Mediator.Send(query);
      }
  
  }
  </code></pre>
  
  <p>And the RAZOR verion doesn't return the JSON.. instead it returns.. </p>
  
  <p>nvalidOperationException: Unsupported handler method return type 'System.Threading.Tasks.Task<code>1[System.Collections.Generic.IEnumerable</code>1[Srx.Application.StatCategories.Models.StatCategoryPreviewDto]]'.
  Microsoft.AspNetCore.Mvc.RazorPages.Internal.ExecutorFactory.CreateHandlerMethod(HandlerMethodDescriptor handlerDescriptor)</p>
  
  <p>Any idea ? </p>