给出以下类结构
public class Parent
{
public Guid Id { get;
public List<BaseChild> Children { get; set; }
}
public abstract class BaseChild
{
public int Id { get; set; }
public string ChildName { get; set; }
}
public class NormalChild : BaseChild
{
public DateTime BirthDate { get; set; }
}
public class RichChild : BaseChild
{
public List<OffshoreAccount> OffshoreAccounts { get; set; }
}
public class OffshoreAccount
{
public string AccountNumber { get; set; }
public AccountInfo AccountInfo …Run Code Online (Sandbox Code Playgroud) 发布到 aspnetcore api 时,我收到 415 http 错误结果。如果我的端点标记为 [HttpPost] 而不是 [HttpDelete],则不会发生这种情况
在 aspnetcore api 控制器中:
[HttpDelete]
public async Task<IActionResult> Delete([FromBody]EntityViewModel vm)
{
Run Code Online (Sandbox Code Playgroud)
在角度控制器中:
var obj = new Object();
obj.atr1 = 1;
obj.atr2 = 2 ;
$http.post(route, obj)
.then(function (response) {
Run Code Online (Sandbox Code Playgroud)
实体视图模型.cs
public class EntityViewModel
{
public int Atr1 { get; set; }
public int Atr2 { get; set; }
}
Run Code Online (Sandbox Code Playgroud)