簡體   English   中英

如何在Simple Injector中注冊Asp.net Identity Role Manager

[英]How to register Asp.net Identity Role Manager in Simple Injector

如何使用Simple Injector進行注冊? 目前,我在下面遇到此錯誤

ApplicationRoleManager類型的構造函數包含名稱為“ store”的參數,並且類型IRoleStore尚未注冊。 請確保已注冊IRoleStore,或更改ApplicationRoleManager的構造函數。

public class ApplicationRoleManager : RoleManager<IdentityRole>
    {

        public ApplicationRoleManager(IRoleStore<IdentityRole, string> store) : base(store)
        {
        }

        public static ApplicationRoleManager Create(IdentityFactoryOptions<ApplicationRoleManager> options,
            IOwinContext context)
        {
            var appRoleManager = new ApplicationRoleManager(new RoleStore<IdentityRole>(context.Get<ApplicationDbContext>()));
            return appRoleManager;
        }
    }

在簡單的注射器上,我有以下代碼,但錯誤仍然存​​在

container.RegisterPerWebRequest<RoleManager<IdentityRole,string>,ApplicationRoleManager>();

僅作記錄,以防萬一有人遇到與我相同的問題,這是我發現的內容,也可以在此處找到

container.Register<ApplicationRoleManager>(Lifestyle.Scoped);

container.Register<IRoleStore<IdentityRole, string>, RoleStore<IdentityRole>>(
    Lifestyle.Scoped);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM