I am trying to implement mediatr pattern in ASP.Net Web Api.
Getting the following error:
Handler was not found for request of type MediatR.IRequestHandler`2[Orion_API.Campaigns.GetCampaigns.GetCampaignsRequest,System.Collections.Generic.List`1[Orion_API.Campaigns.GetCampaigns.GetCampaignsResponse]]. Register your handlers with the container.
My bootstrapper class is as follows:
builder.RegisterApiControllers(Assembly.GetExecutingAssembly());
builder.RegisterGeneric(typeof(GenericRepository<>))
.As(typeof(IGenericRepository<>))
.InstancePerRequest();
builder.RegisterType<Mediator>().As<IMediator>().InstancePerLifetimeScope();
builder.Register<ServiceFactory>(context =>
{
var componentContext = context.Resolve<IComponentContext>();
return t => {
object o;
return componentContext.TryResolve(t, out o) ? o : null;
};
});
//Set the dependency resolver to be Autofac.
Container = builder.Build();