I am converting a classic ASP application to a .NET 2.0 application and I am having problems trying to figure out how to pass parameters when making the HTTP call.
In my classic ASP I have the following code
strSend = "fields="&returnFields&"&pernr="&eIDs
Set xml = Server.CreateObject("Microsoft.XMLHTTP")
xml.Open "POST", "http://mypioneer.phibred.com/ews/post", False
xml.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
xml.Send strSend - where I am passing the parameters
In the ASP.NET page I have coded so far
Dim strPostData As
String = "fields=" & strFieldInfo &
"&username=" & strUsername
Dim myHttpWebRequest As HttpWebRequest = WebRequest.Create("http://mypioneer.phibred.com/ews/post")
i have an asp page,with the username & password,and i want from my .net web application to POST data to the login page,and then get the response of that page.....how can i get that response......and check for it.
blancomario
Member
5 Points
1 Post
How to pass parameters with HTTPWebRequest?
May 02, 2006 02:50 PM|LINK
I am converting a classic ASP application to a .NET 2.0 application and I am having problems trying to figure out how to pass parameters when making the HTTP call.
In my classic ASP I have the following code
strSend = "fields="&returnFields&"&pernr="&eIDs
Set xml = Server.CreateObject("Microsoft.XMLHTTP")
xml.Open "POST", "http://mypioneer.phibred.com/ews/post", False
xml.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
xml.Send strSend - where I am passing the parameters
In the ASP.NET page I have coded so far
Dim strPostData As String = "fields=" & strFieldInfo & "&username=" & strUsername Dim myHttpWebRequest As HttpWebRequest = WebRequest.Create("http://mypioneer.phibred.com/ews/post")myHttpWebRequest.Method = "post"
myHttpWebRequest.ContentType = "application/x-www-form-urlencoded"
I can figure what method to use so I can pass the strPostData as the parameter like it was done in the classic ASP sample above.
I appreciate your help.
joteke
All-Star
46284 Points
6896 Posts
ASPInsiders
MVP
Re: How to pass parameters with HTTPWebRequest?
May 02, 2006 07:33 PM|LINK
Hi,
you would get the request stream with call to GetRequestStream and then using the returned stream, you'd write the params.
Please see: http://msdn2.microsoft.com/en-us/library/system.net.httpwebrequest.getrequeststream(VS.80).aspx
Teemu Keiski
Finland, EU
marafacs
Member
77 Points
51 Posts
MVP
Re: How to pass parameters with HTTPWebRequest?
Oct 03, 2006 07:46 AM|LINK
Dear joteke,
i have an asp page,with the username & password,and i want from my .net web application to POST data to the login page,and then get the response of that page.....how can i get that response......and check for it.
Mostafa M.Arafa Elzoghbi
C# MVP,MCT,MCSD.Net,MCTS
Follow me on Twitter: @mostafaelzoghbi
danish321
Member
2 Points
1 Post
Re: How to pass parameters with HTTPWebRequest?
Jan 17, 2008 10:18 AM|LINK
Hi blancomario .
Dim strPostData As String = "fields=" & strFieldInfo & "&username=" & strUsername
Dim myHttpWebRequest As HttpWebRequest = WebRequest.Create("http://mypioneer.phibred.com/ews/post")
myHttpWebRequest.Method = "post"
myHttpWebRequest.ContentType = "application/x-www-form-urlencoded"
after building the post data then write it on the URL like below given code.
StreamWriter postwriter = new StreamWriter(myHttpWebRequest dsds.GetRequestStream());postwriter.Write(postData);
postwriter.Close();
Hope this helps [:)]
ASP.NET