1、【懒得安分博客总结的很全面】
2、关于基础类型作入参数的问题
参照此博客【ASP.NET WebAPI String 传值问题】
3、代码说明
using System; using System.Collections.Generic; using System.Linq; using System.Net; using System.Net.Http; using System.Web.Http; using PosWebAPi.Models; using Newtonsoft.Json; namespace PosWebAPi.Controllers {/// <summary> /// /// </summary> public class PosController : ApiController { /// <summary> /// 测试 /// </summary> /// <returns></returns> [HttpGet] public string Test() { return "Hello Word"; } /// <summary> /// 总接口 /// </summary> /// <param name="sInput"></param> /// <returns></returns> [HttpPost] public Result<object> ProcCYZZSY(string sInput) { return WorkServices.PosService._ProcCYZZSY(sInput); } [HttpPost] public Result<object> Amt(string sInput) { // var s= JsonConvert.SerializeObject(sInput); //var str = Convert.ToString(sInput); // Posinput pos = new Posinput(); // JsonConvert.DeserializeObject(sInput); return new Result<object>(true,"OK", sInput); // return WorkServices.PosService._Amt(sInput); } [HttpPost] public Result<object> Amt22(Msg msg) { return new Result<object>(true, "", msg.msg1); } public class Msg { public string msg1 { get; set; } } } }