private async void loginbtn_Click(object sender, RoutedEventArgs e) { apiCallStatusText.Text = string.Empty; if (usernamebox.Text.Length == 0) { usernameStatusText.Text = "Please enter a username"; } else { usernameStatusText.Text = string.Empty; if (passwordBox.Password.Length == 0) { passwordStatusText.Text = "Please enter a password"; } else { passwordStatusText.Text = string.Empty; //MessageDialog md = new MessageDialog($"Username : {usernamebox.Text} \n Password : {passwordBox.Password}"); //await md.ShowAsync(); try { String token = await uvm.AuthenticateUser(usernamebox.Text, passwordBox.Password); if (token == null) { throw new Exception(); } User user = await uvm.GetUserDetails(token); if (user != null) { Globals.LoggedInUser = user; apiCallStatusText.Text = "Login succesful"; Frame rootFrame = Window.Current.Content as Frame; rootFrame.Navigate(typeof(TravellistsView)); } else { throw new Exception(); } } catch (Exception) { apiCallStatusText.Text = "Error while trying to login. Try again later ..."; } } } }