Link to home
Start Free TrialLog in
Avatar of mfalconmtz
mfalconmtz

asked on

HttpWebRequest with GET and POST

I want to send data to a url via HttpWebRequest in ASP.net but I need to send some data via GET method and another data via POST method, is it possible? How do I send it?
Avatar of philipjonathan
philipjonathan
Flag of New Zealand image

Are you saying that you want to send both GET and POST data in the same request. I think that's possible. You can encode the GET data as Query String, but still set the request method as POST and write the POST data into the request stream.
Avatar of mfalconmtz
mfalconmtz

ASKER

If I use:

req = CType(WebRequest.Create("http://mydomain/Link.aspx?opt=0949889EA5EA&type=simple&pass=False"), HttpWebRequest)

I send opt, type and pass via GET?
Well, to be correct, actually you are sending those through query string. However, if you are making GET request, the only way you can pass parameters is also through query string.
Btw, what do you want to achieve actually? Maybe if you can tell use more, we can provide better suggestion ...
ASKER CERTIFIED SOLUTION
Avatar of MonkeyPushButton
MonkeyPushButton
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I want to suscribe e-mail addresses to a mailing list via code, the form to suscribe to this list send query string parameters and the name and e-mail address with a POST like this.


<form method="POST" action="http://mydomain/Link.aspx?opt=0949889EA5EA&type=simple&pass=False">
<input type="text" name="name">
<input type="text" name="email">
</form>

Open in new window

SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial