Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net web api 将';ObjectContent`1';类型未能序列化内容类型';的响应正文;应用程序/xml;字符集=utf-8';在执行webapi时_Asp.net Web Api - Fatal编程技术网

Asp.net web api 将';ObjectContent`1';类型未能序列化内容类型';的响应正文;应用程序/xml;字符集=utf-8';在执行webapi时

Asp.net web api 将';ObjectContent`1';类型未能序列化内容类型';的响应正文;应用程序/xml;字符集=utf-8';在执行webapi时,asp.net-web-api,Asp.net Web Api,我在执行以下web api方法时遇到运行时错误 The 'ObjectContent`1' type failed to serialize the response body for content type 'application/xml; charset=utf-8'. web api控制器 [Route("api/movies")] public IHttpActionResult Get() { var movies = _movieBusiness.GetAllMovie

我在执行以下web api方法时遇到运行时错误

The 'ObjectContent`1' type failed to serialize the response body for content type 'application/xml; charset=utf-8'.
web api控制器

[Route("api/movies")]
public IHttpActionResult Get()
{
    var movies = _movieBusiness.GetAllMovies();
    return Ok(movies);
}
业务逻辑方法

public List<Movie> GetAllMovies()
        {
            var movies = _movieRepository.GetMovies();
            _unitOfWork.Dispose();
            return movies;
        }
公共列表GetAllMovies() { var movies=_movieRepository.GetMovies(); _unitOfWork.Dispose(); 返回电影; } 数据存取方法

public List<Movie> GetMovies()
        {
            var query = "dbo.spGetMovies";
            var list = SqlMapper.Query<Movie>(_unitOfWork.GetConnection(), query, commandType: CommandType.StoredProcedure);
            return list;

        }
public List GetMovies()
{
var query=“dbo.spGetMovies”;
var list=SqlMapper.Query(_unitOfWork.GetConnection(),Query,commandType:commandType.storedProcess);
退货清单;
}

问题已经解决。原因是DTO项目中的程序集具有过时的Newtonsoft.json dll。更新DLL对我有效。

是否存在内部异常,其中包含有关对象序列化失败原因的详细信息?将内容复制到流时出错。