如何使用C#检索传入参数?

时间:2018-08-18 11:45:31

标签: c# json api asp.net-core

我正在使用ASP.NET Core MVC 2.0与waboxapp API(link)集成。

一些参数已经发布了

 let storyboard = UIStoryboard(name: "Main", bundle: nil)
let dVC: ViewController2 = storyboard.instantiateViewController(withIdentifier: "Your vc2 stroryboard identifier") as! ViewController2
 self.navigationController?.pushViewController(dVC, animated: true)

我尝试了以下代码:

contact[uid], contact[name], contact[type], message[uid], message[body] etc...

检索传入参数的正确方法是什么?

1 个答案:

答案 0 :(得分:1)

对于waboxapp,其请求为标准HTTP格式(application / x-www-form-urlencoded)。尝试执行以下步骤:

  1. 模型

    public class Waboxapp
    {
        public string Token { get; set; }
        public Contact Contact { get; set; }
    }
    public class Contact
    {
        public string Name { get; set; }
        public string Type { get; set; }
    }
    
  2. 操作

        [HttpPost]
    public IActionResult WaboxappFromForm([FromForm]Waboxapp waboxapp)
    {
        return View();
    }
    
  3. 请求
    enter image description here

  4. 结果 enter image description here