Click here to Skip to main content
16,003,315 members
Home / Discussions / C#
   

C#

 
GeneralRe: How do you save images loaded in a Microsoft Web Browser Control? Pin
kayhustle26-Aug-04 14:17
kayhustle26-Aug-04 14:17 
GeneralRe: How do you save images loaded in a Microsoft Web Browser Control? Pin
Heath Stewart26-Aug-04 14:20
protectorHeath Stewart26-Aug-04 14:20 
GeneralRe: How do you save images loaded in a Microsoft Web Browser Control? Pin
kayhustle26-Aug-04 15:23
kayhustle26-Aug-04 15:23 
GeneralRe: How do you save images loaded in a Microsoft Web Browser Control? Pin
Heath Stewart27-Aug-04 8:56
protectorHeath Stewart27-Aug-04 8:56 
GeneralRe: How do you save images loaded in a Microsoft Web Browser Control? Pin
kayhustle27-Aug-04 10:21
kayhustle27-Aug-04 10:21 
GeneralRe: How do you save images loaded in a Microsoft Web Browser Control? Pin
Heath Stewart27-Aug-04 10:25
protectorHeath Stewart27-Aug-04 10:25 
GeneralRe: How do you save images loaded in a Microsoft Web Browser Control? Pin
kayhustle27-Aug-04 11:44
kayhustle27-Aug-04 11:44 
GeneralRe: How do you save images loaded in a Microsoft Web Browser Control? Pin
Heath Stewart27-Aug-04 11:57
protectorHeath Stewart27-Aug-04 11:57 
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]
QuestionQ. How do you start 2 or more other classes to threading from a single Form1?? Pin
gman4426-Aug-04 12:57
gman4426-Aug-04 12:57 
AnswerRe: Q. How do you start 2 or more other classes to threading from a single Form1?? Pin
kayhustle26-Aug-04 13:25
kayhustle26-Aug-04 13:25 
AnswerRe: Q. How do you start 2 or more other classes to threading from a single Form1?? Pin
LongRange.Shooter27-Aug-04 10:15
LongRange.Shooter27-Aug-04 10:15 
GeneralLooking for someone who is familiar with iTextSharp library (PDF files creating) Pin
Member 103390726-Aug-04 12:13
Member 103390726-Aug-04 12:13 
GeneralRe: Looking for someone who is familiar with iTextSharp library (PDF files creating) Pin
Heath Stewart26-Aug-04 13:38
protectorHeath Stewart26-Aug-04 13:38 
GeneralRe: Looking for someone who is familiar with iTextSharp library (PDF files creating) Pin
Member 103390727-Aug-04 10:51
Member 103390727-Aug-04 10:51 
Generalreading NTFS Master File Table Pin
redjoy26-Aug-04 11:58
redjoy26-Aug-04 11:58 
GeneralRe: reading NTFS Master File Table Pin
Anonymous26-Aug-04 12:49
Anonymous26-Aug-04 12:49 
Generaladding an item to a listview Pin
yitzstokes26-Aug-04 10:05
yitzstokes26-Aug-04 10:05 
GeneralRe: adding an item to a listview Pin
Nick Parker26-Aug-04 11:46
protectorNick Parker26-Aug-04 11:46 
GeneralWhen is Archer's Inside C# 3rd edition slated for publishing Pin
Joe Woodbury26-Aug-04 10:04
professionalJoe Woodbury26-Aug-04 10:04 
GeneralRe: When is Archer's Inside C# 3rd edition slated for publishing Pin
Jon Sagara26-Aug-04 14:57
Jon Sagara26-Aug-04 14:57 
General.Net applications in Linux Pin
vadim_3k26-Aug-04 9:21
sussvadim_3k26-Aug-04 9:21 
GeneralRe: .Net applications in Linux Pin
leppie26-Aug-04 9:30
leppie26-Aug-04 9:30 
GeneralRe: .Net applications in Linux Pin
Judah Gabriel Himango26-Aug-04 9:34
sponsorJudah Gabriel Himango26-Aug-04 9:34 
GeneralRe: .Net applications in Linux Pin
Heath Stewart26-Aug-04 10:36
protectorHeath Stewart26-Aug-04 10:36 
GeneralRe: .Net applications in Linux Pin
Nick Parker26-Aug-04 11:43
protectorNick Parker26-Aug-04 11:43 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.