0

我有一个带有 Autofac 的 web api 应用程序。对于输入插入模型,我需要对指示相关实体的属性使用验证属性。

public class Comment
    {
        [Required]
        [ExistentBookValidationAttribute]
        public int BookId { get; set; }
    }

ExistentBookValidationAttribute我需要访问业务服务来进行验证。由于 Autofac 不会将属性注入验证属性,因此我决定使用依赖解析器手动获取服务。但我不想使用GlobalConfiguration.Configuration.DependencyResolver. 我想DependencyResolver从 web api使用HttpConfiguration。那有可能吗?HttpConfiguration.DependencyResolver在验证属性中可以访问吗?

4

0 回答 0