【发布时间】:2017-08-04 08:24:34
【问题描述】:
我正在使用asp.net web api,我的客户端在vuejs中,我传递一个带有json的对象,如下所示:
[
{
"key": "Table",
"rows": 1,
"cols": 1,
"cells": 1
},
{
"key": "Paragraph",
"text": "asda",
"fontSize": 14
},
{
"key": "Paragraph",
"text": "asda",
"fontSize": 14
},
{
"key": "Paragraph",
"text": "asda",
"fontSize": 14
}
]
我需要在端点接收它,此时我到达端点但我的数据始终为空。
这是我的控制器:
public async Task<IHttpActionResult> CreateDocument([FromBody]DocumentDetails atributes)
{
return Ok(atributes);
}
简单的事情,只是为了看看我是否收到数据,我创建了一个 DocumentDetails 对象,因为我收到的数据是一个列表,我有这样的东西:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace server.Models
{
public class DocumentDetails
{
public int Id { get; set; }
public List<DocumentAtributes> atributes { set; get; }
}
}
它有一个 DocumentAtributes 类型的列表,其中应该是列表中的所有数据:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace server.Models
{
public class DocumentAtributes
{
public int Id { get; set; }
public String key { get; set; }
public String rows { get; set; }
public String cols { get; set; }
public String cells { get; set; }
public String fontSize { get; set; }
public String width { get; set; }
public String height { get; set; }
public String base64 { get; set; }
public String align { get; set; }
public String text { get; set; }
}
}
谢谢你们!
【问题讨论】:
标签: c# asp.net asp.net-web-api controller