【发布时间】:2014-10-24 04:06:54
【问题描述】:
我有一个 SpecialRequest 类,里面只有一个键。
public class SpecialRequest
{
public string Key { get; set; }
}
一个简单的控制器
public class ValuesController : ApiController
{
// GET api/values
public SpecialRequest Get()
{
return new CodeRequest {SecretKey = "ABSDCV"};
}
// POST api/values
public string Post(SpecialRequest specialRequest)
{
string temp = specialRequest.Key + "-TESTING";
return temp;
}
}
使用提琴手我 POST 到 Post,我可以看到它在调试器中被击中,但 POST 的主体未绑定到 Post 方法中的 specialRequest 参数。
Fiddler Headers :
User-Agent: Fiddler
Host: localhost:64180
Content-Length: 66
Content-Type: text/xml
Request Body:
<CodeRequest>
<SecretKey>
Hello
</SecretKey>
</CodeRequest>
我忘了做什么?
【问题讨论】:
标签: post binding asp.net-web-api fiddler