本文介绍了Asp.net web api,httppost发送两个参数。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在asp.net web api HttpPost中发送两个参数?假设我不想改变MapRoute。
我尝试过:
// POST:api / Settings / 163/20
[HttpPost]
public bool PostSetting([FromRoute] int facilityId,int bandwidthRequest)
{
if(!ModelState.IsValid)
{
返回HttpBadRequest(ModelState);
}
How can I send two parameters in asp.net web api HttpPost? Assume that I don't want to change MapRoute.
What I have tried:
// POST: api/Settings/163/20
[HttpPost]
public bool PostSetting([FromRoute] int facilityId,int bandwidthRequest)
{
if (!ModelState.IsValid)
{
return HttpBadRequest(ModelState);
}
推荐答案
[Route("api/YOURCONTROLLER/{paramOne}/{paramTwo}")]
public string PostSetting(int paramOne, int paramTwo)
{
}
The {} names need to match your parameters.</pre>
这篇关于Asp.net web api,httppost发送两个参数。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!