❔ Weird issue with MediaR pipeline.

I have such a typical pipeline UnhandledExceptionBehaviour, which executes before executing command.

And it's works fine, for example for this kind of request:
    [HttpPost("addnewguest")]
    public async Task<ActionResult<string>> AddNewGuest(CreateGuestCommand command)
    {
        return await Mediator.Send(command);
    }


But when there is no content, this pipeline is omitted. For example:
   [HttpPost("mergeguests")]
    public async Task<ActionResult> MergeGuests(MergeGuestsCommand command)
    {
        await Mediator.Send(command);

        return NoContent();
    }


It is the request:
public record MergeGuestsCommand : IRequest


There used to be a
public record MergeGuestsCommand : IRequest<Unit>
,
but I read to remove <Unit> in the new version of MediaR and it caused the code to no longer work as it used to.

Why?
Was this page helpful?