By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,238 Members | 1,746 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,238 IT Pros & Developers. It's quick & easy.

HttpWebRequest configured with Method "POST" still generating "GET

P: n/a
I have been working on a little project in C# to log into a website (using
code inspired/riipped from
http://www.codeproject.com/cs/intern...ivejournal.asp) but when I
request the response, the packet that is sent out is an HTTP GET (I'm
watching the outgoing packet via Ethereal). The code I'm using is identical
to that above, only configured for the site I'm trying to communicate with.

Are there any ideas out there for why a HttpWebRequest wouldn't "POST" when
you've clearly told it to post, and when you've given it properly formatted
content to post?

Any help would be much appreciated.
Jul 23 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
ReGex <Re***@discussions.microsoft.comwrote:
I have been working on a little project in C# to log into a website (using
code inspired/riipped from
http://www.codeproject.com/cs/intern...ivejournal.asp) but when I
request the response, the packet that is sent out is an HTTP GET (I'm
watching the outgoing packet via Ethereal). The code I'm using is identical
to that above, only configured for the site I'm trying to communicate with.
Could you post a short but complete program which demonstrates the
problem?

See http://www.pobox.com/~skeet/csharp/complete.html for details of
what I mean by that.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Jul 23 '06 #2

P: n/a
After further analyzing the packet data going out (and trying the same code,
although targeted at a different server) I noticed that the HttpWebRequest
was attempting to discourse with the server *prior* to the post event.
Apparently it was trying to negotiate whether it was the right place to send
a post, before actually sending it (and in this case the server was saying
no, because it sends a 302 redirect back on post). By switching off the
static member System.Net.ServicePointManager.Expect100Continue, it now posts
to the server as expected. (* see
http://haacked.com/archive/2004/05/15/449.aspx for a more thorough discussion
of this problem *)

However, now that it's posting, the posting isn't working as expected, but
at least I can debug that :)

"Jon Skeet [C# MVP]" wrote:
ReGex <Re***@discussions.microsoft.comwrote:
I have been working on a little project in C# to log into a website (using
code inspired/riipped from
http://www.codeproject.com/cs/intern...ivejournal.asp) but when I
request the response, the packet that is sent out is an HTTP GET (I'm
watching the outgoing packet via Ethereal). The code I'm using is identical
to that above, only configured for the site I'm trying to communicate with.

Could you post a short but complete program which demonstrates the
problem?

See http://www.pobox.com/~skeet/csharp/complete.html for details of
what I mean by that.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Jul 24 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.