为什么路由在asp.net核心的HttpDelete中不起作用?

时间:2019-11-05 12:35:22

标签: routing

我有一个带有HttpDelete请求的api。但是当我调用它时,每次参数为null。

我检查了一下,不起作用:

[HttpDelete("{id}")]
public async Task<IActionResult> Delete([FromRoute] DeletePersonnelCommand command)
{
    .....
}

public class DeletePersonnelCommand : ICommand
{
    public Guid Id { get; }

    [JsonConstructor]
    public DeletePersonnelCommand(Guid id)
    {
        Id = id;
    }
}

我也对此进行了研究。但不起作用:

[HttpDelete("delete/{id:guid}")]
public async Task<IActionResult> Delete([FromRoute] DeletePersonnelCommand command)
{
    await Dispatcher.SendAsync(command);
    return Ok();
}

0 个答案:

没有答案
相关问题