오류 'ObjectContent`1'유형이 콘텐츠 유형 'application / json;에 대한 응답 본문을 직렬화하지 못했습니다. charset = utf-8 '

말릭 카슈미르

데이터베이스에서 모든 사용자를 가져 오기 위해 웹 API를 작성 The 'ObjectContent 1' type failed to serialize the response body for content type 'application/json; charset=utf-8'.중이지만 이미 webapiconfig.cs 파일과 웹 API에 대한 모든 전제 조건을 추가했습니다.

WebApi

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] 삭제

에서 수정
0

몇 마디 만하겠습니다

0리뷰
로그인참여 후 검토

관련 기사

Related 관련 기사

뜨겁다태그

보관