我目前在调用我的 webapi 时遇到以下错误消息。
{"Message":"发生错误。","ExceptionMessage":"'ObjectContent`1' 类型未能序列化内容类型 'application/json; charset=utf-8' 的响应正文
下面是我的代码
public User getUser(string userName)
{
UserDAO userDao = db.GetDAO<UserDAO>();
var user = userDao.GetWhere(x => x.Username == userName).ToList();
if (user.Count < 1)
{
//the user is not yet in the database.
return new User { UserId = -1 };
}
return user.FirstOrDefault();
}