作者:伍贤厚_197 | 来源:互联网 | 2023-09-18 18:45
WhenImupdatingarowinthedatabaseIgetthiserror:http:snag.gy975mW.jpg当我更新数据库中的一行时,我得到这
When I'm updating a row in the database I get this error: http://snag.gy/975mW.jpg
当我更新数据库中的一行时,我得到这个错误:http://snag.gy/975mW.jpg
Since it's a 500 error I'm guessing it's something in my C# code giving me this error, the strange thing is that the database gets updated and nothing crashes. So I'm wondering how I could debug this error? I'm sending the data from angular to a web api.
因为这是500个错误,我猜是在我的c#代码中,给了我这个错误,奇怪的是数据库得到了更新,没有崩溃。我想知道如何调试这个错误?我将数据从角度发送到web api。
$scope.editUser = function () {
var user = $scope.selectedUser;
UserService.editUser(user).success(function (data) {
console.log('Updated', data)
}).
error(function () {
$scope.error = console.log('Something went wrong')
});
}
[HttpPost]
public User EditUser([FromBody]EditUserModel model)
{
var editedUser = db.Users.FirstOrDefault(u => u.UserID == model.UserID);
editedUser.FirstName = model.FirstName;
editedUser.LastName = model.LastName;
editedUser.Email = model.Email;
db.SaveChanges();
return editedUser;
}
1 个解决方案