I am using the below code for calling Google translator but getting an error.
using System; using System.Net; using System.Security.Authentication;
namespace ConsoleApp3 { class Program { static void Main(string[] args) { Console.WriteLine("Hello World!"); string input="Hello"; string languagePair="En/Fr";
string url = String.Format("http://www.google.com/translate_t?hl=en&ie=UTF8&text={0}&langpair={1}",
input, languagePair);
WebClient webClient = new WebClient();
webClient.Encoding = System.Text.Encoding.UTF8;
string result = webClient.DownloadString(url);
result = result.Substring(result.IndexOf("id=result_box") + 22,
result.IndexOf("id=result_box") + 500);
result = result.Substring(0, result.IndexOf("</div"));
Console.WriteLine(result);
Console.ReadLine();
}
}
}
Error : 'dotnet.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\2.1.6\System.Security.Claims.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled. 'dotnet.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\2.1.6\System.Resources.ResourceManager.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled. Exception thrown: 'System.Net.WebException' in System.Net.WebClient.dll An unhandled exception of type 'System.Net.WebException' occurred in System.Net.WebClient.dll The SSL connection could not be established, see inner exception. Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.
The program '[15956] dotnet.exe' has exited with code -1 (0xffffffff).
User contributions licensed under CC BY-SA 3.0