0
在执行以下Web API方法我正在运行时的时间误差错误'ObjectContent`1'类型无法序列化内容类型'application/xml;字符集= UTF-8' ,而执行的WebAPI
The 'ObjectContent`1' type failed to serialize the response body for content type 'application/xml; charset=utf-8'.
网页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;
}
数据访问方法
public List<Movie> GetMovies()
{
var query = "dbo.spGetMovies";
var list = SqlMapper.Query<Movie>(_unitOfWork.GetConnection(), query, commandType: CommandType.StoredProcedure);
return list;
}
是否存在内部异常,其中包含有关对象未能序列化的更多详细信息? – David
将内容复制到流时出错。 – Tom