1
私のXamarinフォームを使用して、WebAPIプロジェクトのコントローラのアクションにデータを送信するPOST要求を作成する作業を進めています。ブレークポイントでのコードは、私が名前空間のSystem.Net.Httpを持っており、コードに記載されているシステムを使用してXamarinフォーム投稿のリクエストHTTPの問題
client.BaseAddress = new Uri("192.168.79.119:10000");
を超えません。
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;
}
は、その文字列またはパラメータとして
Model.Email
を送信し、そのアクションにPOSTリクエストを作るための方法とが必要です。
例外が発生していないことは確実ですか? URI文字列 – Jason
にスキーム(「http://」)を追加してみてください。しかしそれはまだ投稿しません。 –
でも問題は何ですか?例外、メッセージなどありますか? – Eru