这是Asp.Net网络表单应用 - 这是我POST方法在我Apicontroller
公共无效后([FromBody]字符串值){}我与小提琴手后处理。结果我这样做了实验。结果但事实并非如此。
有什么问题。结果你能帮忙吗?
我试过了,我失败了。
公共无效后(MyViewModel模型){ 串AA = model.Value;}公共类MyViewModel{ 公共字符串值{获得;组; }}在提琴手:
请求正文:值=哈坎解决方案
在提琴手POST正文有效载荷应该是:
= foo_bar这样的名称而不是:
值= foo_bar这样的名称这只是那些关于模型在Web API中结合奇怪的事情之一。如果你想支持值= foo_bar这样的名称在POST体内的有效载荷,你可以总是写一个视图模型:
公共类MyViewModel{ 公共字符串值{获得;组; }},然后让你的方法采取这种观点模型参数:
公共无效后(MyViewModel模型){ ......与model.Value在这里工作如常}This is Asp.Net Webform application This is my POST method in my Apicontroller
public void Post([FromBody]string value) { }I'm with fiddler post process. I did so experiment. But it did not.
What is the problem. Can you help?
I've tried it, I've failed.
public void Post(MyViewModel model) { string aa = model.Value; } public class MyViewModel { public string Value { get; set; } }In Fiddler:
Request Body: Value=hakan解决方案
The POST body payload in Fiddler should be:
=foo_barinstead of:
value=foo_barThat's just one of those strange things about the model binding in the Web API. If you want to support value=foo_bar in the POST body payload you could always write a view model:
public class MyViewModel { public string Value { get; set; } }and then have your method take this view model as parameter:
public void Post(MyViewModel model) { ... work with model.Value here as usual }
更多推荐
FromBody值GET空
发布评论