Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > How do I transfer user to another server after POST

Reply
Thread Tools

How do I transfer user to another server after POST

 
 
Piotr Strycharz
Guest
Posts: n/a
 
      04-22-2004
Hi all

I do have a problem.

How can I transfer user to another server using POST. The problem is that
Server.Transfer (preserves form data) works just in current server.
Response.Redirect - uses GET method. However I have to open remote server
page using POST method. Normally this can be achieved using <form
ACTION="remote-page-url"> tag. However this is impossible with ASP.NET.
Also, using WebRequest class is not good solution, as I can post to and read
data from remote server, but user browser itselft is still connected to my
server.

Regards.


 
Reply With Quote
 
 
 
 
Patrice
Guest
Posts: n/a
 
      04-22-2004
TYhis is not an ASP.NET limitation (an "ASP.NET" page is anyway just an
HTML Page). At worst you could do something like a pure HTML Page that
contains the data as hidden field and that posts to the target page when
loaded...

That said I'm not sure it works (depending perhaps on user settings) as IMO
posting accross domains may sometimes be blocked ?

What thinks the owner of the page. Perhaps could a provide a GET version ?

Patrice

"Piotr Strycharz" <(E-Mail Removed)> a écrit dans le
message de news:c683r7$83e$(E-Mail Removed)...
> Hi all
>
> I do have a problem.
>
> How can I transfer user to another server using POST. The problem is that
> Server.Transfer (preserves form data) works just in current server.
> Response.Redirect - uses GET method. However I have to open remote server
> page using POST method. Normally this can be achieved using <form
> ACTION="remote-page-url"> tag. However this is impossible with ASP.NET.
> Also, using WebRequest class is not good solution, as I can post to and

read
> data from remote server, but user browser itselft is still connected to my
> server.
>
> Regards.
>
>



 
Reply With Quote
 
 
 
 
Piotr Strycharz
Guest
Posts: n/a
 
      04-22-2004

Użytkownik "Patrice" <(E-Mail Removed)> napisał w wiadomości
news:%(E-Mail Removed)...
> TYhis is not an ASP.NET limitation (an "ASP.NET" page is anyway just an
> HTML Page).


Well - actually it is. I cannot provide my ACTION element in FORM

> What thinks the owner of the page. Perhaps could a provide a GET version ?


Not possible. It is credit card verifier that allows parameters only as POST
data due to security reasons.

Piotr

 
Reply With Quote
 
Patrice
Guest
Posts: n/a
 
      04-22-2004
Sorry, I meant actually this is not an *HTML* limitation. Let's proceed with
take 2 hopefully more clearly.

You could then change the action attribute client side using JavaScript.

My first suggestion expressed more clearly was to create an HTML page by
yourself (using response.write). You could keep your current ASP.NET page
and on postback response.write those fields as hidden value on a page that
is immediatly submitted (using JavaScript)...

As a side note, I don't really understand why the user should be really
directed to the verification site. Shouldn't the verification process be
transparent to the user and see he is still on your site ?

Patrice


"Piotr Strycharz" <(E-Mail Removed)> a écrit dans le
message de news:c68e9g$2k1$(E-Mail Removed)...
>
> Użytkownik "Patrice" <(E-Mail Removed)> napisał w wiadomości
> news:%(E-Mail Removed)...
> > TYhis is not an ASP.NET limitation (an "ASP.NET" page is anyway just an
> > HTML Page).

>
> Well - actually it is. I cannot provide my ACTION element in FORM
>
> > What thinks the owner of the page. Perhaps could a provide a GET version

?
>
> Not possible. It is credit card verifier that allows parameters only as

POST
> data due to security reasons.
>
> Piotr
>



 
Reply With Quote
 
Rick Spiewak
Guest
Posts: n/a
 
      04-23-2004
You can create the post yourself
Here's some code I use to post a credit card transaction, which returns to
the caller. You can then redirect to an acknowledgement page:

Private Function viaKlixPostTransaction(ByVal trans As
viaKlixTransaction) As String
modErr.EnterFunction("OrderForm.aspx.vb.viaKlixPos tTransaction")
Dim sbldr As New StringBuilder
Dim params As NameValueCollection = trans.GetValues
Dim iEnum As IEnumerator = params.Keys.GetEnumerator

' Build the request string from the parameters
Do While iEnum.MoveNext
Dim sKey As String = iEnum.Current
If Not params.Item(sKey) Is Nothing AndAlso
params.Item(sKey).ToString <> "" Then
sbldr.Append(sKey)
sbldr.Append("=")
sbldr.Append(Server.UrlEncode(params.Item(sKey)))
sbldr.Append("&")
End If
Loop
sbldr.Remove(sbldr.Length - 1, 1) 'Remove trailing "&"

'Post the request
Dim dataResponse As String
Dim dataBody As String = sbldr.ToString
Dim webResponse As HttpWebResponse
Dim webRequestStream As System.IO.Stream
Dim webRequest As HttpWebRequest
Dim responseStream As Stream

' Create the RequestStream
Try
webRequest =
webRequest.Create("https://www2.viaklix.com/process.asp")

' Note - "KeepAlive = False" seems to be needed to avoid errors,
apparently caused by the client
' (this application) thinking the connection is being
maintained while the server or
' firewall may disconnect it. Apparently, if the client
doesn't maintain it, it will know
' enough to re-establish it when it needs it.
webRequest.KeepAlive = False

webRequest.Method = "POST"
webRequest.ContentType = "application/x-www-form-urlencoded"

' Create request body
webRequest.ContentLength = dataBody.Length
webRequestStream = webRequest.GetRequestStream()
Catch ex As Exception
modErr.WriteLog("Creating RequestStream: " & ex.ToString, 0)
End Try

' Write the WebRequest
Try
Dim writer As New StreamWriter(webRequestStream)
writer.Write(dataBody)
'TODO - writer.close can probably go into a Finally block...
Try 'Getting an exception on this shouldn't stop us...
writer.Close() 'Closes the StreamWriter and the underlying
stream
Catch ex As Exception
modErr.WriteLog("Writer.Close: " & ex.ToString, 0)
End Try

Catch ex As Exception ' Catches error on writer.write
modErr.WriteLog(ex.ToString, 0)
modErr.WriteLog(dataBody, 1) 'Looking for data dependency
modErr.ExitFunction()
Return Nothing

End Try

' Get the response from viaKlix
Try
webResponse = webRequest.GetResponse()
responseStream = webResponse.GetResponseStream()

Dim readStream As New System.IO.StreamReader(responseStream)
dataResponse = readStream.ReadToEnd

readStream.Close() 'Closes the StreamReader and the underlying
stream

modErr.ExitFunction()
Return dataResponse

Catch ex As Exception
modErr.WriteLog("Reading Response: " & ex.ToString, 0)
modErr.ExitFunction()
Return Nothing
End Try

End Function

"Piotr Strycharz" <(E-Mail Removed)> wrote in message
news:c68e9g$2k1$(E-Mail Removed)...
>
> Użytkownik "Patrice" <(E-Mail Removed)> napisał w wiadomości
> news:%(E-Mail Removed)...
> > TYhis is not an ASP.NET limitation (an "ASP.NET" page is anyway just an
> > HTML Page).

>
> Well - actually it is. I cannot provide my ACTION element in FORM
>
> > What thinks the owner of the page. Perhaps could a provide a GET version

?
>
> Not possible. It is credit card verifier that allows parameters only as

POST
> data due to security reasons.
>
> Piotr
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Transfer administrator settings to another user Patrick Cleburne Computer Support 7 06-01-2010 08:52 PM
Post file from server to another server - Urgent help required Badri Narayanan ASP General 4 03-31-2005 01:24 PM
How to access: a page from a User control, and another User controlfrom another one? qwerty ASP .Net 3 09-30-2004 05:32 PM
006~ASP 0230~Server.Transfer Error~The call to Server.Transfer failed while load Jim ASP General 1 01-28-2004 06:37 PM
Post post post. Shel-hed Computer Support 2 11-08-2003 07:41 AM



Advertisments