Search code examples
c#restopenrasta

Openrasta Validators Issue


I am facing a strange issue with Validators in OpenRasta.I have entry in my configuration file for Validator

ResourceSpace.Uses.CustomDependency<IValidator<Customer>, CustomerValidator>(DependencyLifetime.PerRequest);

I am testing my API using REST Client.While making a call to my API method in handler, validator is not getting called every time.I feel that i am making some mistakes in my configuration.

Can anybody let me know what needs to be done for fixing this?


Solution

  • Changed Dependency Lifetime from PerRequest To Transient for both ResourceValidationInterceptor and CustomerValidator as Follows.

    ResourceSpace.Uses.CustomDependency<IOperationInterceptor, ResourceValidationInterceptor>(DependencyLifetime.Transient);
    
    ResourceSpace.Uses.CustomDependency<IValidator<Customer>, CustomerValidator>(DependencyLifetime.Transient);
    

    that solved my issue.