데이터베이스에서 모든 사용자를 가져 오기 위해 웹 API를 작성 The 'ObjectContent 1' type failed to serialize the response body for content type 'application/json; charset=utf-8'.
중이지만 이미 webapiconfig.cs 파일과 웹 API에 대한 모든 전제 조건을 추가했습니다.
using Atea.Azure.ApiManagement.Entities;
using Atea.Azure.ApiMangement.Business;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
namespace Azure_API_Delegation_Portal.Controllers
{
public class ApisController : ApiController
{
private readonly IUserService _userService;
public ApisController(IUserService userService)
{
_userService = userService;
}
// GET api/<controller>
public IEnumerable<User> GetAllUsers()
{
return _userService.AllUser();
}
}
}
이렇게해야합니다.
public JsonResult GetAllUsers()
{
return Json(_userService.AllUser(), JsonRequestBehavior.AllowGet)
}
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다