我正在尝试使用WEB API返回一个人列表,但我没有成功。我正在使用依赖注入(SOA体系结构)
<Error>
<Message> Error. </ Message>
<ExceptionMessage>
The type 'ObjectContent`1' could not serialize the response body for the content type application / xml; set of characters = utf-8 '.
</ ExceptionMessage>
<ExceptionType> System.InvalidOperationException </ ExceptionType>
<StackTrace />
<InnerException>
<Message> Error. </ Message>
我的方法如下:
public class CuentaController : ApiController
{
private IUsurioESContrato _servicePerson;
public CuentaController()
{
_servicePerson = new UsuarioESImplementacion();
}
[HttpGet]
public IEnumerable GetListPersona()
{
PersonaModel model = new PersonaModel();
model.ListPersona = _servicePerson.ListarPersonas();
return model.ListPersona;
}
它的工作方式与此类似,但其目的是使用模型
public IEnumerable<Persona> GetListPersona()
{
return _servicePerson.ListarPersonas().ToList();
}
如何使用模型来实现方法而不调用主类?