The error message tells you the problem. You are trying to convert the value to an int.
StatusCode is of type
HttpStatusCode(an Enum)[
^] which won't convert unless you explicitly cast it.
You could do:
statusCode = (int)((HttpWebResponse)e.Response).StatusCode;
which is exactly what you are doing here:
Quote:
statusCode = (int)hwresponse.StatusCode;