1
カスタムモデルバインダーを使用して、モデルBindingにカスタムロジックを配置しています。カスタムモデルバインダー:パラメータ 'xxx'は、その上に競合する属性があるためバインドできません。
ここに私のDTOです: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を持っています。):
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:
public class StepDto
{
public int Id { get; set; }
[MaxLength(100)]
public string Description { get; set; }
public StepType StepType { get; set; }
}
ResourceDTO
この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",