I have a try catch around some code that gets a response from a web request. The following is the code
var token = "";
try
{
var response = req.GetResponse();
using (var sReader = new streamReader(response.GetResponseStream()))
{
token = sReader.ReadToEnd();
}
catch (webException we)
{
token = "ERROR: " + we;
}
catch (Exception e)
{
Token = "ERROR: " + e;
}
This line -
var response = req.GetResponse();
is the one that fails. The fact it fails is a different issue that I'm working on with a different group.
The problem is the catch statement only catches the error on 2 of the 3 test machines. The third one it doesn't catch and I get a unhandled exception error.
What I have tried:
Somewhere I read that the issue could be a mismatch .NET version, so I've made sure the app targets .NET 4.6 and all 3 machines have 4.6 or greater installed.
Machine 1 - Windows 10, .NET 4.6.2 - catch block works
Machine 2 - Server 2008, .NET 4.6 - catch block works
Machine 3 - Server 2008, .NET 4.6 - catch block does not work.
What else can I look at?