Quantcast
Channel: Active questions tagged blazor - Stack Overflow
Viewing all articles
Browse latest Browse all 4839

Mediatr behavior pipeline does not work in new Blazor App

$
0
0

I'm trying to create a new Blazor App in .NET 8, using Mediatr, and I created a custom behavior pipeline for MediatR to handle some validations, using FluentValidation. However it seems to be getting ignored and it is not called.

public class ValidatorBehavior<TRequest, TResponse>(ILogger<ValidatorBehavior<TRequest, TResponse>> logger,IEnumerable<IValidator<TRequest>> validators): IPipelineBehavior<TRequest, TResponse>where TRequest : IRequest<TResponse>{//implementation here}

And this is how i registered it

private static void RegisterMediatorBehavior(this MediatRServiceConfiguration configuration){ArgumentNullException.ThrowIfNull(configuration);configuration.AddOpenBehavior(typeof(ValidatorBehavior<,>));}services.AddMediatR(cfg =>{cfg.RegisterServicesFromAssemblies(AppDomain.CurrentDomain.GetAssemblies());cfg.RegisterMediatorBehavior();});

Before that I tried to register it as a transient service, still no luck.

Any ideas?


Viewing all articles
Browse latest Browse all 4839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>