public static async Task KickOffHosting(string[] args) { try { var retryCounter = 0; while (retryCounter < 3 && string.IsNullOrWhiteSpace(ClientKey)) { string key; if (string.IsNullOrWhiteSpace(ClientKeyDecryptionKey)) { Console.WriteLine("Type in key:"); key = Console.ReadLine(); } else { key = ClientKeyDecryptionKey; } try { retryCounter++; ClientKey = AESHelper.DecryptStringFromBase64_Aes(ClientKeyEncrypted, key, null); ClientKeyDecryptionKey = key; } catch (Exception ex) { Console.WriteLine($"Probably wrong key: {ex}"); ClientKeyDecryptionKey = null; } } if (string.IsNullOrWhiteSpace(ClientKey)) { Console.WriteLine("Cannot decrypt key. Not starting hosting."); return; } if (string.IsNullOrWhiteSpace(CurrentClientToken) || DateTime.Now > CurrentTokenTTL) { var myProcess = new System.Diagnostics.Process(); myProcess.StartInfo.UseShellExecute = true; myProcess.StartInfo.FileName = RedirectUrl; myProcess.Start(); } var hostBuilder = CreateWebHostBuilder(args); IWebHost webHost = hostBuilder.Build(); var task = webHost.RunAsync(CancellableShellHelper.CancellationToken); await task; } catch (Exception ex) { Console.WriteLine(ex.Message); } }