こんにちは私はユーザ名とパスワードを入力してログインボタンをクリックするとログイン画面を持つXamarinフォームアプリケーションを開発しています。 。しかし、私だけで、ログイン失敗したメッセージにXamarinフォームのログインページが私のWebサービスに接続していません
EDITを得ることをやっていないです:
The certificate for this server is invalid. You might be connecting to a server that is pretending to be “service.brainstorminstruments.com” which could put your confidential information at risk.
HERESに私のXAMLコード:
<?xml version="1.0" encoding="UTF-8"?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="LoginNavigation.LoginPage" Title="Login">
<ContentPage.ToolbarItems>
<ToolbarItem Text="Sign Up" Clicked="OnSignUpButtonClicked" />
</ContentPage.ToolbarItems>
<ContentPage.Content>
<StackLayout VerticalOptions="StartAndExpand">
<Label Text="Username" />
<Entry x:Name="usernameEntry" Placeholder="username" />
<Label Text="Password" />
<Entry x:Name="passwordEntry" IsPassword="true" />
<Button Text="Login" Clicked="OnLoginButtonClicked" />
<Label x:Name="messageLabel" />
</StackLayout>
</ContentPage.Content>
</ContentPage>
EDIT今、私は次のエラーでのiOS上でクラッシュを取得します
using System;
using System.Collections.Generic;
using System.Net.Http;
using Newtonsoft.Json;
using Xamarin.Forms;
namespace LoginNavigation
{
public partial class LoginPage : ContentPage
{
public LoginPage()
{
InitializeComponent();
}
async void OnSignUpButtonClicked (object sender, EventArgs e)
{
await Navigation.PushAsync (new SignUpPage());
}
async void OnLoginButtonClicked (object sender, EventArgs e)
{
var postContent = new FormUrlEncodedContent(new[] {
new KeyValuePair<string, string>("username","usernameEntry"),
new KeyValuePair<string, string>("password","passwordEntry")
});
var httpClient = new HttpClient();
var serverResponse = await httpClient.PostAsync("https://service.brainstorminstruments.com/api/login", postContent);
var serverResponseString = await serverResponse.Content.ReadAsStringAsync();
//theEditor.Text = serverResponseString;
Response theResponseObject = JsonConvert.DeserializeObject<Response>(serverResponseString);
if (theResponseObject.status == "success") {
App.IsUserLoggedIn = true;
Navigation.InsertPageBefore (new MainPage(), this);
await Navigation.PopAsync();
} else {
messageLabel.Text = "Login failed";
passwordEntry.Text = string.Empty;
theEditor.Text += theResponseObject.status + "\n";
theEditor.Text += theResponseObject.message + "\n";
}
}
}
}
01:私はHERESに間違ったクラス
の背後にあるコードを使用していました
私はhttpクライアントに新しいので、どんな助けも素晴らしいだろう!
ありがとうございます!以下のすべての項目のリストのうち
あなたが実際にあなたが任意のエラー・コードやメッセージのために戻ってサーバから取得応答を調べたことがありますか?あなたがすべての応答を得ているなら、それはサーバーに接続できたことを意味します。 – Jason
@Jason私は – Phoneswapshop
を持っていません。なぜ、両方のページにサインアップとログインハンドラがありますか?あなたは正しいものを呼んでいると確信していますか? – Jason