1
我正在使用我的Xamarin表单将数据发送到我的控制器中的Action在我的WebAPI项目中的POST请求。带断点的代码不会超越Xamarin表单发布请求Http问题
client.BaseAddress = new Uri("192.168.79.119:10000");
我有命名空间System.Net.Http和using代码中提到的系统。
private void BtnSubmitClicked(object sender, EventArgs eventArgs)
{
System.Threading.Tasks.Task<HttpResponseMessage> statCode = ResetPassword();
App.Log(string.Format("Status Code", statCode));
}
public async Task<HttpResponseMessage> ResetPassword()
{
ForgotPassword model = new ForgotPassword();
model.Email = Email.Text;
var client = new HttpClient();
client.BaseAddress = new Uri("192.168.79.119:10000");
var content = new StringContent(
JsonConvert.SerializeObject(new { Email = Email.Text }));
HttpResponseMessage response = await client.PostAsync("/api/api/Account/PasswordReset", content); //the Address is correct
return response;
}
需要一种方法来使POST请求到行动和发送该字符串或Model.Email
作为参数。
你确定它没有抛出异常吗?尝试添加一个方案(“http://”)到URI字符串 – Jason
这似乎有所帮助!但它仍然不会发布。 –
但问题是什么?你有异常,一些消息等? – Eru