没有给出的参数对应于'IOwinContext.Get <T>(string)'所需的形式参数'key'

Kha*_*nte 2 asp.net-mvc owin

我正在尝试将个人资料图片添加到我的项目中,我正在关注这篇文章 https://social.technet.microsoft.com/wiki/contents/articles/34445.mvc-asp-net-identity-customizing-for-adding -profile-image.aspx#Step_4_IdentityModels_cs ,在文章中有一部分我必须获取用户详细信息才能加载用户的图像.在这一步,我在标题中得到错误,我错过了什么?

    public FileContentResult UserPhoto()
    {
        if (User.Identity.IsAuthenticated)
        {
            String userId = User.Identity.GetUserId();
            if (userId == null)
            {
                string filename = 
  HttpContext.Server.MapPath(@"~/Uploads/ProfilePictures/blankprofile.png");
                byte[] imageData = null;
                FileInfo fileInfo = new FileInfo(filename);
                long imageFileLength = fileInfo.Length;
                FileStream fs = new FileStream(filename, FileMode.Open, 
                FileAccess.Read);
                BinaryReader br = new BinaryReader(fs);
                imageData = br.ReadBytes((int)imageFileLength);
                return File(imageData, "image/png");
            }
            // to get the user details to load user Image
            var bdUsers = 
            HttpContext.GetOwinContext().Get<ApplicationDbContext>();
            var userImage = bdUsers.Users.Where(x => x.Id == 
            userId).FirstOrDefault();
            return new FileContentResult(userImage.ProfilePicture, 
            "image/jpeg");
        }
        else
        {
            string fileName      =HttpContext.Server.MapPath(@"~/Uploads/ProfilePictures/blankprofile.png");

            byte[] imageData = null;
            FileInfo fileInfo = new FileInfo(fileName);
            long imageFileLength = fileInfo.Length;
            FileStream fs = new FileStream(fileName, FileMode.Open, 
            FileAccess.Read);
            BinaryReader br = new BinaryReader(fs);
            imageData = br.ReadBytes((int)imageFileLength);
            return File(imageData, "image/png");             
        }

    }
Run Code Online (Sandbox Code Playgroud)

Kha*_*nte 9

您必须引用具有您正在寻找的get方法的类的Microsoft.aspnet.identity.owin nuget包