以下代码用于跨平台解决方案。
var auth = new SigninModel
{
Username = username,
Password = password
};
var stringContent = new StringContent(JsonConvert.SerializeObject(auth), Encoding.UTF8, "application/json");
var response = await Client.PostAsync("http://localhost:54019/api/AuthenticationApi/Login", stringContent);
以下是我的网络服务代码
[System.Web.Http.Route("api/AuthenticationApi/Login/")]
[System.Web.Http.AcceptVerbs("GET", "POST")]
[System.Web.Http.HttpPut]
public DBResult Login(AuthenticationModel model)
{
return new DBResult {}
}