POST and redirect

Discussion in 'ASP .Net' started by ETK, Nov 15, 2004.

  1. ETK

    ETK Guest

    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
     
    ETK, Nov 15, 2004
    #1
    1. Advertising

  2. 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" <> wrote in message
    news:cna4a2$hfc$...
    > 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
    >
     
    Ken Cox [Microsoft MVP], Nov 15, 2004
    #2
    1. Advertising

  3. ETK

    ETK Guest

    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]" <> wrote in message
    news:...
    > 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" <> wrote in message
    > news:cna4a2$hfc$...
    >> 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
    >>

    >
     
    ETK, Nov 15, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. La Jesus
    Replies:
    9
    Views:
    1,323
    Gunnar Hjalmarsson
    Oct 27, 2003
  2. Darren Oakey

    Redirect and POST

    Darren Oakey, Dec 19, 2003, in forum: ASP .Net
    Replies:
    2
    Views:
    538
    vMike
    Dec 19, 2003
  3. POST AND REDIRECT IN C#

    , May 12, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    7,309
  4. David

    HTTP Post and Redirect?

    David, Jul 13, 2005, in forum: ASP .Net
    Replies:
    6
    Views:
    40,031
    biguenique
    Mar 21, 2009
  5. Sal
    Replies:
    1
    Views:
    532
Loading...

Share This Page