469,925 Members | 1,519 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,925 developers. It's quick & easy.

POST and redirect

ETK
Hi,
I need to POST data to some aspx page and after that redirect to this page
( page isn't on my local server where my page is). Is it possible to do this
from aspx code on server side?
Thanks,
Dalibor
Nov 18 '05 #1
2 3751
Hi Dalibor,

You could use the Webclient class for this. You need to know the names of
the Posted controls. Then do you response.redirect:
Sub DoPost()
Dim uriString As String = _
"http://localhost/p4320work/mySpecialPage.aspx"
Dim strGoName As String
strGoName = TextBox1.Text
' Create a new WebClient instance.
Dim myWebClient As New System.Net.WebClient
Dim myNameValueCollection As New _
System.Collections.Specialized.NameValueCollection
myNameValueCollection.Add("go1", strGoName)
myNameValueCollection.Add("Button1", "")
Dim responseArray As Byte() = myWebClient.UploadValues _
(uriString, "POST", myNameValueCollection)
Response.Redirect("http://msdn.microsoft.com/")
End Sub

Let us know if this helps?

Ken
Microsoft MVP [ASP.NET]

"ETK" <da***********@ericsson.com> wrote in message
news:cn**********@newstree.wise.edt.ericsson.se...
Hi,
I need to POST data to some aspx page and after that redirect to this page
( page isn't on my local server where my page is). Is it possible to do
this from aspx code on server side?
Thanks,
Dalibor


Nov 18 '05 #2
ETK
Hi Ken,
I get next error: "The underlying connection was closed: Unable to connect
to the remote server.". I think that it is because I have to use PROXY
(probably I should set proxy settings somewhere in code). I'll try to solve
this.
But it seems to me that when I do Response.Redirect on the some page I do
POST, that it is a new request for page and page wouldn't get data my page
have to post. I need to post data and redirect with posted data to this page
(show result in browser).

Thanks,
Dalibor

"Ken Cox [Microsoft MVP]" <BA************@sympatico.ca> wrote in message
news:eS**************@TK2MSFTNGP15.phx.gbl...
Hi Dalibor,

You could use the Webclient class for this. You need to know the names of
the Posted controls. Then do you response.redirect:
Sub DoPost()
Dim uriString As String = _
"http://localhost/p4320work/mySpecialPage.aspx"
Dim strGoName As String
strGoName = TextBox1.Text
' Create a new WebClient instance.
Dim myWebClient As New System.Net.WebClient
Dim myNameValueCollection As New _
System.Collections.Specialized.NameValueCollection
myNameValueCollection.Add("go1", strGoName)
myNameValueCollection.Add("Button1", "")
Dim responseArray As Byte() = myWebClient.UploadValues _
(uriString, "POST", myNameValueCollection)
Response.Redirect("http://msdn.microsoft.com/")
End Sub

Let us know if this helps?

Ken
Microsoft MVP [ASP.NET]

"ETK" <da***********@ericsson.com> wrote in message
news:cn**********@newstree.wise.edt.ericsson.se...
Hi,
I need to POST data to some aspx page and after that redirect to this
page ( page isn't on my local server where my page is). Is it possible to
do this from aspx code on server side?
Thanks,
Dalibor

Nov 18 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by David E. Smith | last post: by
10 posts views Thread by Dave Smithz | last post: by
11 posts views Thread by Alex Hunsley | last post: by
5 posts views Thread by =?Utf-8?B?QWxleCBNYWdoZW4=?= | last post: by
5 posts views Thread by MikeB | last post: by
56 posts views Thread by UKuser | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.