1

내 모델 바인딩에 사용자 지정 논리를 적용하기 위해 사용자 지정 모델 바인더를 사용하고 있습니다.사용자 지정 모델 바인더 : 'xxx'매개 변수가 충돌 속성을 가지고 있기 때문에 바인딩 할 수 없습니다.

public class TaskDto 
{ 
    public int Id { get; set; } 

    [MaxLength(100), Required] 
    public string Name { get; set; } 

    public List<StepDto> Steps { get; set; } 

    public List<ResourceDTO> Resources { get; set; } 
} 

단계 DTO : 여기

내 DTO들입니다

public class StepDto 
{ 
    public int Id { get; set; } 

    [MaxLength(100)] 
    public string Description { get; set; } 

    public StepType StepType { get; set; } 
} 

ResourceDTO : ResourceType이 열거

public class ResourceDTO 
{ 
    public int Id { get; set; } 

    [MaxLength(250), Required] 
    public string Title { get; set; } 

    [Required] 
    public string Link { get; set; } 

    public string MetaTagUrl { get; set; } 

    [Required, Range(1, 1)] 
    public ResourceType ResourceType { get; set; } 
} 

(. 단지 지금은 값으로 1을 가지고)

link을 사용하여 사용자 정의 모델 바인더를 만들려고했습니다.

[HttpPut] 
    [Route("datacapture/{activityId}/tasks")] 
    [Authorize] 
    public async Task<IHttpActionResult> UpdateAllDataCaptureActivities(int activityId, [FromBody][ModelBinder] TaskDto tasks) 
    { 
     ... 
    } 

내가 API를 호출에 다음과 같은 오류가 점점 오전 :

은 여기 내 API의 조치 방법 서명의

"Message": "An error has occurred.", 
    "ExceptionMessage": "Can't bind parameter 'tasks' because it has conflicting attributes on it.", 
    "ExceptionType": "System.InvalidOperationException", 

답변

4

같은에서 [ModelBinder를] [FromBody] 사용하지 마십시오 시각.