小编Kha*_*nte的帖子

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

我正在尝试将个人资料图片添加到我的项目中,我正在关注这篇文章 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 …
Run Code Online (Sandbox Code Playgroud)

asp.net-mvc owin

2
推荐指数
1
解决办法
808
查看次数

标签 统计

asp.net-mvc ×1

owin ×1