It is not possible, at least directly, only in 4.5 upwards. O . NET 2.0 has not been supported for quite some time and should not be used, it does not receive security updates.
Who knows how to catch the source and adapt for use (but it is not something trivial).
Use and improve the code:
using (var client = new WebClient()) {
return client.UploadString(url, xml);
}
I put in the Github for future reference.
Much simpler, right? Capturing the exception is only causing problems for the code. Just capture the exception to make something useful. What you’re doing is just spoiling the stack trace.
Who negatively could tell how it is possible to do this in . NET 2.0
– Maniero