【问题标题】:Why Database Storing [object object] type为什么数据库存储[object object]类型
【发布时间】:2016-11-25 11:43:38
【问题描述】:

我正在尝试上传文件以及一些列。文件上传成功但为什么剩余列采用 [object object] 类型

表格

public partial class CreateUserIdentity
    {
        public int Id { get; set; }
        public string Email { get; set; }
        public string Image { get; set; }
        public string password { get; set; }
    }

AngularJs

     var description = {
                Passwoed: $scope.FileDescription,
             Email :    $scope.Email
            }
            FileUploadService.UploadFile($scope.SelectedFileForUpload, description

                ).then(function (d) {
});

Mvc 控制器

 [HttpPost]
         public JsonResult SaveFiles(string description)
       {
           if (Request.Files != null)
           {
              CreateUserIdentity f = new CreateUserIdentity
                   {
                       Image = actualFileName,
                        Email = description,
                   };
                   using (ProjectsEntities dc = new ProjectsEntities())
                   {
                       dc.CreateUserIdentities.Add(f);
                       dc.SaveChanges();
                       Message = "File uploaded successfully";
                       flag = true;
                   }
               }

 return new JsonResult { Data = new { Message = Message, Status = flag } };

【问题讨论】:

    标签: angularjs model-view-controller


    【解决方案1】:

    您发送的description 不是string - 它是一个由EmailPasswoed 组成的对象 - 在您的休息控制器中正确输入并使用Email = description.Email

    您可以谨慎地从角度侧发送$scope.Email,而不是将其包装在description-Object 中,这应该也可以(如果您不需要属性Passwoed)。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-10-06
      • 2016-06-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-07-03
      • 2013-10-20
      • 2011-07-13
      相关资源
      最近更新 更多