0
.netコア1.1.1を使用してアプリケーションを覗きます 現在のユーザーがタグヘルパーの管理者ロールのメンバーであるかどうかを確認する必要があります。私は例外を持っているコメントのない文字列isAdmin = await userManager.IsInRoleAsync(currentUser, "admin")
を残す場合.net core IsInRoleAsync 'System.ObjectDisposedException'
public override async void Process(TagHelperContext context, TagHelperOutput output)
{
currentUser = await userManager.GetUserAsync(actionContextAccessor.ActionContext.HttpContext.User);
isAdmin = await userManager.IsInRoleAsync(currentUser, "admin");
}
:TagHelperのコンストラクタは、Processメソッドをオーバーライドし
public MyTagHelper(UserManager<User> UserManager, IActionContextAccessor ActionContextAccessor)
{
userManager = UserManager;
actionContextAccessor = ActionContextAccessor;
}
ある「タイプの未処理の例外 『をSystem.ObjectDisposedException』システムで発生しました。 Private.CoreLib.ni.dll "
理由を理解できません。 ありがとうございます。
ありがとうございます。できます。 – gikerix
あなたは歓迎ですが、ここに誰かに感謝する最善の方法は、彼らの答えを受け入れ、それをupvoteすることです。 (私の答えの左側にある緑色の矢印と上向き矢印をクリックしてください) –