You have a major error in your code - though it's a good workaround to solving your problem: anything that implements IDisposable - including (and especially!) Graphics and Bitmap - should be disposed when you're finished. A good way in C# is like so:
using (Graphics g1 = control.CreateGraphics())
{
// ...
}
The using block makes sure that Dispose is called, even in case of error. It amounts to this:
Graphics g1 = control.CreateGraphics();
try
{
// ...
}
finally
{
if (g1 != null) g1.Dispose();
}
Actually, the object is always cast to IDisposable in the finally block so that explicit interface implementations are handled correctly, but I didn't want to confuse you. Other than that, this should work. If you don't dispose your Graphics and Bitmaps above, you'll be leaking resources (memory). Note that you don't have to dispose of controls, though. All Control derivatives encapsulates window handles (HWNDs) that are automatically destroyed. Disposing them is not necessary. In order to see why you're getting HTTP 400, you need to take a look at the HTTP request and response. A simple packet sniffer will help. Make sure that you're also requesting https://... A poorly implemented HTTP daemon expecting an SSL socket connection may return 400. There's many other reasons why this might be failing, however. If you're POSTing data from a web browser, for example, you need to do it again (but can be dangerous! you don't want to order a $4,500 segway twice now, do you?!). Like I said, the source of your error judging by your description is impossible to determine. You just have to get down and dirty and debug your code, including the HTTP request and responses sent from both your web browser (i.e., the WebBrowser control that you're embedding) as well as your HttpWebRequest and HttpWebResponse. This posting is provided "AS IS" with no warranties, and confers no rights. Software Design Engineer Developer Division Sustained Engineering Microsoft [My Articles]