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?
ASP.NET.NET Programming

Avatar of undefined
Last Comment
philipjonathan

8/22/2022 - Mon
philipjonathan

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.
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?
philipjonathan

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 ...
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck
ASKER CERTIFIED SOLUTION
MonkeyPushButton

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
mfalconmtz

ASKER
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
philipjonathan

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.