digitaldaku
asked on
How to make an HTTP Post request from inside ASP .Net Page and also trasfer the page
Hi,
I am stuck in a situation where I have to make a http web request to another website's web page(asp) from withing the ASP .Net application and also pass the control to that ASP page.
Means I want use HttpWebRequest classes and also want to do server.trasfer. but the final page should be able to get the values passed by using Request.form("values") .
Please guide me.
Thanks
Atul
I am stuck in a situation where I have to make a http web request to another website's web page(asp) from withing the ASP .Net application and also pass the control to that ASP page.
Means I want use HttpWebRequest classes and also want to do server.trasfer. but the final page should be able to get the values passed by using Request.form("values") .
Please guide me.
Thanks
Atul
ASKER
Many thanks for above code.
Using the above code, the receiving page will not able to use request.form("posted values from sending page") .
I want to create a http post and also redirect to the page....so that the receiving page can receive those values.
I cannot use get method since the data will be visible in the URL and is sensitive.
Please help !
Once again thanks
Using the above code, the receiving page will not able to use request.form("posted values from sending page") .
I want to create a http post and also redirect to the page....so that the receiving page can receive those values.
I cannot use get method since the data will be visible in the URL and is sensitive.
Please help !
Once again thanks
Adding postData is easy.. look at the URLs
Dim postData
postData = "field1=" & request.form("field1")
postData = postData & "&field2=" & request.form("field2")
Call objHTTP.open("POST", url, False)
Call objHTTP.send "Content-Type", "application/x-www-form-ur lencoded"
Call objHTTP.send postData
How is the data visible?
CJ
Dim postData
postData = "field1=" & request.form("field1")
postData = postData & "&field2=" & request.form("field2")
Call objHTTP.open("POST", url, False)
Call objHTTP.send "Content-Type", "application/x-www-form-ur
Call objHTTP.send postData
How is the data visible?
CJ
ASKER
Thanks for your immediate response.
I am trying to run this....
What is your opinion?
objRequest = CType(WebRequest.Create("http://xyz/dmz/abc.asp" ), HttpWebRequest)
objRequest.Method = "POST"
objRequest.ContentType = "application/x-www-form-ur lencoded"
objRequest.MaximumAutomati cRedirecti ons = 1
objRequest.AllowAutoRedire ct = True
'create message body
encoding = New UTF8Encoding()
arrRequest = encoding.GetBytes(UrlStrin g.ToString )
objRequest.ContentLength = arrRequest.Length
strmRequest = objRequest.GetRequestStrea m()
strmRequest.Write(arrReque st, 0, arrRequest.Length)
strmRequest.Close()
I am trying to run this....
What is your opinion?
objRequest = CType(WebRequest.Create("http://xyz/dmz/abc.asp"
objRequest.Method = "POST"
objRequest.ContentType = "application/x-www-form-ur
objRequest.MaximumAutomati
objRequest.AllowAutoRedire
'create message body
encoding = New UTF8Encoding()
arrRequest = encoding.GetBytes(UrlStrin
objRequest.ContentLength = arrRequest.Length
strmRequest = objRequest.GetRequestStrea
strmRequest.Write(arrReque
strmRequest.Close()
ASKER
Sorry missed the point..... The above request is not transferring the web page to asp page.
you are doing a post.
Where is the redirect?
CJ
Where is the redirect?
CJ
ASKER
Many thanks CJ you are the only hope for me to come out of this deep ocean of problem somehow I am stuck and feel like lost.
if I will do the redirect using response.redirect I lose all the values of the HTTP Post or should I do the redirect after execute the above code... I think that will be another request and I know I will lose all the POST values.
Please advice how should achieve the above goal..... I have to pass values from a .aspx page to a .asp page.
Once again thanks...
AB
if I will do the redirect using response.redirect I lose all the values of the HTTP Post or should I do the redirect after execute the above code... I think that will be another request and I know I will lose all the POST values.
Please advice how should achieve the above goal..... I have to pass values from a .aspx page to a .asp page.
Once again thanks...
AB
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Many thanks.
After all those tries I have reverted back in using URL based get method.
Thanks for your efforts.
AB
After all those tries I have reverted back in using URL based get method.
Thanks for your efforts.
AB
No comment has been added to this question in more than 21 days, so it is now classified as abandoned.
I will leave the following recommendation for this question in the Cleanup topic area:
Accept: cheekycj {http:#9786828}
Any objections should be posted here in the next 4 days. After that time, the question will be closed.
pinaldave
EE Cleanup Volunteer
I will leave the following recommendation for this question in the Cleanup topic area:
Accept: cheekycj {http:#9786828}
Any objections should be posted here in the next 4 days. After that time, the question will be closed.
pinaldave
EE Cleanup Volunteer
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaskdr/html/askgui10012002.asp
http://www.code101.com/Code101/DisplayArticle.aspx?cid=23
<%
Dim strHTML ' for response
Dim url ' url to post and redirect to
url = "http://somedain.com/page1.asp"
Set objHTTP = Server.CreateObject("MSXML
Call objHTTP.open("GET", url, False)
Call objHTTP.send
strHTML = objHTTP.responseText
Set objHTTP = Nothing
Response.redirect url
%>
HTH,
CJ