POSTing data with System.Windows.Forms.WebBrowser: Vista vs XP

J

Jeff

I have a C# Winforms app developed with Visual Studio Express Edition
that uses a WebBrowser control to POST data to an external website.
Here is some sample code:

string postStr = "parm1=hello";
postStr += "&parm2=world";
byte[] postBytes =Encoding.UTF8.GetBytes(postStr);
WebBrowser webBrowser = new WebBrowser();
webBrowser.Navigate("http://www.mydomain.com/post_here",
"_blank", postBytes, "Content-Type: application/x-www-form-urlencoded"
+ "\n" + "\r");


This works just fine when the app runs in Windows XP, but with Vista,
the data isn't properly posted. After further investigation, I did a
network trace (with ethereal), and discovered that while the XP
instance sent a HTTP POST with my data (correct), Vista sent a HTTP
GET, resulting in the error. Is there a known issue with
System.Windows.Forms.WebBrowser POSTing data on Vista?
 
P

Patrick Steele

I have a C# Winforms app developed with Visual Studio Express Edition
that uses a WebBrowser control to POST data to an external website.

I would try using the WebRequest classes for this sort of thing.
Probably much lighter than the WebBrowser class and you'll have more
control:

http://tinyurl.com/99v7
 
J

Jeff

I would try using the WebRequest classes for this sort of thing.
Probably much lighter than the WebBrowser class and you'll have more
control:

Thanks for your response, Patrick. I think the WebBrowser control is
appropriate for my application, because I was the user to be navigated
to the POSTed page. I had a fully functional implementation that
suited my needs for Windows XP, but the same code doesn't work in
Vista, so I really do think this is a bug that should be addressed.
In any event, I worked around the problem by having my program create
a .html file embedded with javascript POSTing code and then
WebBrowser.Navigate-ing to the html file.

-jeff
 
P

Patrick Steele

Thanks for your response, Patrick. I think the WebBrowser control is
appropriate for my application, because I was the user to be navigated
to the POSTed page.

Ahhh. I see. Yeah, if you need to do browsing too, the WebBrowser
class is what you need.
In any event, I worked around the problem by having my program create
a .html file embedded with javascript POSTing code and then
WebBrowser.Navigate-ing to the html file.

Glad you got it fixed!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top