I have a web api application with Autofac. For the input insert models I need to use validation attributes for the properties that indicate related entities.
public class Comment
{
[Required]
[ExistentBookValidationAttribute]
public int BookId { get; set; }
}
In ExistentBookValidationAttribute
I need to access a business service to do the validation. Since Autofac doesn't inject properties to the validation attributes I decided to use the dependency resolver to get the service manually. But I don't want to use GlobalConfiguration.Configuration.DependencyResolver
. I'd like to use DependencyResolver
from web api HttpConfiguration
. So is that possible? Is HttpConfiguration.DependencyResolver
accessable in the validation attributes?