public async Task <IActionResult> SendMessage([FromBody] Message message) { connection = new HubConnectionBuilder() .WithUrl(hubUrl) .Build(); await connection.StartAsync(); var aesEncriptedMesage = AesCryptoHelper.EncryptString_Aes(message.MessageContent); await connection.InvokeAsync("SendMessage", message.User, aesEncriptedMesage); return(new OkResult()); }
private async void sendButton_Click(object sender, RoutedEventArgs e) { try { var aesEncriptedMesage = AesCryptoHelper.EncryptString_Aes(messageTextBox.Text); await connection.InvokeAsync("SendMessage", userTextBox.Text, aesEncriptedMesage); } catch (Exception ex) { messagesList.Items.Add(ex.Message); } }