473,382 Members | 1,622 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

POST to Non-ASP.NET Site

I am trying to simulate a post to a page that is on another server and is
not implemented in ASP.NET.

I've found some examples for this using WebRequest. That code appears to
work and the data is getting posted to the intended site.

However, I need to redirect to that site, bringing the target site up in the
browser just as though I had clicked a Submit button within a <formtag.

I'm finding surprising little about doing this on the Web. I'm surprised
others aren't running into this.

Thanks for any tips.

--
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com

Nov 2 '07 #1
19 1352
See if this helps:
http://groups.google.com/group/micro...13224a77b89add

Yeah, the POST stuff took a while to figure out.

"Jonathan Wood" <jw***@softcircuits.comwrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
>I am trying to simulate a post to a page that is on another server and is
not implemented in ASP.NET.

I've found some examples for this using WebRequest. That code appears to
work and the data is getting posted to the intended site.

However, I need to redirect to that site, bringing the target site up in
the browser just as though I had clicked a Submit button within a <form>
tag.

I'm finding surprising little about doing this on the Web. I'm surprised
others aren't running into this.

Thanks for any tips.

--
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com

Nov 2 '07 #2
On Nov 2, 5:38 am, "Jonathan Wood" <jw...@softcircuits.comwrote:
I am trying to simulate a post to a page that is on another server and is
not implemented in ASP.NET.

I've found some examples for this using WebRequest. That code appears to
work and the data is getting posted to the intended site.

However, I need to redirect to that site, bringing the target site up in the
browser just as though I had clicked a Submit button within a <formtag.

I'm finding surprising little about doing this on the Web. I'm surprised
others aren't running into this.

Thanks for any tips.

--
Jonathan Wood
SoftCircuits Programminghttp://www.softcircuits.com
How Do I...Make a POST request?
http://samples.gotdotnet.com/quickst...lientPOST.aspx

Nov 2 '07 #3
I wish I had seen that (or maybe it existed) when I was looking... back in
the day!

http://samples.gotdotnet.com/quickst...post.cs&font=3

I think the HttpHelper contains essentially the same elements, but I see the
code sample is handling reserved characters.

Thanks for the post.

"Alexey Smirnov" <al************@gmail.comwrote in message
news:11**********************@o38g2000hse.googlegr oups.com...
On Nov 2, 5:38 am, "Jonathan Wood" <jw...@softcircuits.comwrote:
>I am trying to simulate a post to a page that is on another server and is
not implemented in ASP.NET.

I've found some examples for this using WebRequest. That code appears to
work and the data is getting posted to the intended site.

However, I need to redirect to that site, bringing the target site up in
the
browser just as though I had clicked a Submit button within a <formtag.

I'm finding surprising little about doing this on the Web. I'm surprised
others aren't running into this.

Thanks for any tips.

--
Jonathan Wood
SoftCircuits Programminghttp://www.softcircuits.com

How Do I...Make a POST request?
http://samples.gotdotnet.com/quickst...lientPOST.aspx

Nov 2 '07 #4
Thanks, but I don't see where that link discusses redirecting the browser to
the POSTed results.

--
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com

"Alexey Smirnov" <al************@gmail.comwrote in message
news:11**********************@o38g2000hse.googlegr oups.com...
On Nov 2, 5:38 am, "Jonathan Wood" <jw...@softcircuits.comwrote:
>I am trying to simulate a post to a page that is on another server and is
not implemented in ASP.NET.

I've found some examples for this using WebRequest. That code appears to
work and the data is getting posted to the intended site.

However, I need to redirect to that site, bringing the target site up in
the
browser just as though I had clicked a Submit button within a <formtag.

I'm finding surprising little about doing this on the Web. I'm surprised
others aren't running into this.

Thanks for any tips.

--
Jonathan Wood
SoftCircuits Programminghttp://www.softcircuits.com

How Do I...Make a POST request?
http://samples.gotdotnet.com/quickst...lientPOST.aspx
Nov 2 '07 #5
On Nov 2, 10:17 pm, "Jonathan Wood" <jw...@softcircuits.comwrote:
Thanks, but I don't see where that link discusses redirecting the browser to
the POSTed results.
Please click on the [View Source] link

Nov 3 '07 #6
Yeah, I did that. From what I can tell (I haven't been using .NET that
long), it appears to be a console app that simulates a POST. It then prints
the resulting HTML to the console.

Printing the result in a console app is not the same as redirection. As
indicated, I want the browser to load the resulting page so the user can
navigage from that page. I guess I could sent the results to my page, but
things such as relative links wouldn't work.

I'm already simulating a POST. I got that working. It's the redirection I
can't find anything about.

Did I miss something?

Thanks.

--
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com

"Alexey Smirnov" <al************@gmail.comwrote in message
news:11*********************@50g2000hsm.googlegrou ps.com...
On Nov 2, 10:17 pm, "Jonathan Wood" <jw...@softcircuits.comwrote:
>Thanks, but I don't see where that link discusses redirecting the browser
to
the POSTed results.

Please click on the [View Source] link
Nov 3 '07 #7
"Jonathan Wood" <jw***@softcircuits.comwrote in message
news:Ot*************@TK2MSFTNGP06.phx.gbl...
Other than the annoyance of having the page flash before being redirected,
it does indeed appear to work.
There are all sorts of ways round that...

1) Don't use a postback - instead, have an <input type="button"
onclick="location.href='myotherpage.aspx';" /control, and don't have any
markup on myotherpage.aspx other than something saying "Please wait - about
to redirect you to...." The problem with that, though, is that the
name-value pairs are viewable if you do a View Source really fast...

2) Build the whole thing as an additional <form- you can have as many
<formelements on an aspx page as you like, so long as only one of them
runs server-side. Obviously, that's even worse than 1) in terms of
security...

3) Some fun stuff with <iframes(not recommended...)

4) Use AJAX. Obviously, HttpContext is invalid during a callback, so you
can't just use Response.Redirect. However, there are ways round that too:
http://www.codeproject.com/Ajax/magicajax.asp

Etc...
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Nov 4 '07 #8
Mark,
1) Don't use a postback - instead, have an <input type="button"
onclick="location.href='myotherpage.aspx';" /control, and don't have any
markup on myotherpage.aspx other than something saying "Please wait -
about to redirect you to...." The problem with that, though, is that the
name-value pairs are viewable if you do a View Source really fast...
Well, it's a bit messier. But the name/value pairs are viewable in my
non-ASP.NET version anyway. Probably not a problem but another reason why a
proper .NET solution might be an advantage.
2) Build the whole thing as an additional <form- you can have as many
<formelements on an aspx page as you like, so long as only one of them
runs server-side. Obviously, that's even worse than 1) in terms of
security...
I'm not sure I understand that. It appears that even a <formthat runs
server-side still appears in the final HTML. Since the spec says you can't
nest <formtags, the only way I could see to do this is if you placed
everything outside of the main <formof the page.

--
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com

Nov 4 '07 #9
"Jonathan Wood" <jw***@softcircuits.comwrote in message
news:eu**************@TK2MSFTNGP02.phx.gbl...
>1) Don't use a postback - instead, have an <input type="button"
onclick="location.href='myotherpage.aspx';" /control, and don't have
any markup on myotherpage.aspx other than something saying "Please wait -
about to redirect you to...." The problem with that, though, is that the
name-value pairs are viewable if you do a View Source really fast...

Well, it's a bit messier. But the name/value pairs are viewable in my
non-ASP.NET version anyway. Probably not a problem but another reason why
a proper .NET solution might be an advantage.
The solution I gave you is a proper ASP.NET solution...
>2) Build the whole thing as an additional <form- you can have as many
<formelements on an aspx page as you like, so long as only one of them
runs server-side. Obviously, that's even worse than 1) in terms of
security...

I'm not sure I understand that. It appears that even a <formthat runs
server-side still appears in the final HTML. Since the spec says you can't
nest <formtags, the only way I could see to do this is if you placed
everything outside of the main <formof the page.
Correct.
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Nov 4 '07 #10
Mark,
>>1) Don't use a postback - instead, have an <input type="button"
onclick="location.href='myotherpage.aspx';" /control, and don't have
any markup on myotherpage.aspx other than something saying "Please
wait - about to redirect you to...." The problem with that, though, is
that the name-value pairs are viewable if you do a View Source really
fast...

Well, it's a bit messier. But the name/value pairs are viewable in my
non-ASP.NET version anyway. Probably not a problem but another reason why
a proper .NET solution might be an advantage.

The solution I gave you is a proper ASP.NET solution...
It's implemented using ASP.NET, but the redirection is accomplished via
HTML. As you seemed to be suggesting, being able to do this server-side
would make the information a little more secure.
>I'm not sure I understand that. It appears that even a <formthat runs
server-side still appears in the final HTML. Since the spec says you
can't nest <formtags, the only way I could see to do this is if you
placed everything outside of the main <formof the page.

Correct.
This is the approach I was taking initially. I'm not thrilled with it.

--
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com

Nov 4 '07 #11
"Jonathan Wood" <jw***@softcircuits.comwrote in message
news:eH**************@TK2MSFTNGP03.phx.gbl...
>The solution I gave you is a proper ASP.NET solution...

It's implemented using ASP.NET, but the redirection is accomplished via
HTML. As you seemed to be suggesting, being able to do this server-side
would make the information a little more secure.
I've clearly either confused you, or have not explained properly...

With the solution I gave you, none of the dynamic form is rendered to the
client at all - that's the beauty of it. It's built up server-side, and then
redirected server-side. The first thing the client sees is the response from
the remote server...

In fact, this was the main reason I developed it - specifically, for PayPal
integration with ASP.NET...
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Nov 4 '07 #12
Mark,
With the solution I gave you, none of the dynamic form is rendered to the
client at all - that's the beauty of it. It's built up server-side, and
then redirected server-side. The first thing the client sees is the
response from the remote server...
Then why did I see the generated <formpage flash in my browser before
being redirected. (At least, in your original version of the code.)

--
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com

Nov 4 '07 #13
"Jonathan Wood" <jw***@softcircuits.comwrote in message
news:O5**************@TK2MSFTNGP05.phx.gbl...
>With the solution I gave you, none of the dynamic form is rendered to the
client at all - that's the beauty of it. It's built up server-side, and
then redirected server-side. The first thing the client sees is the
response from the remote server...

Then why did I see the generated <formpage flash in my browser before
being redirected. (At least, in your original version of the code.)
No idea...
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Nov 4 '07 #14
Then why when I said "Other than the annoyance of having the page flash
before being redirected, it does indeed appear to work," you replied "There
are all sorts of ways round that..."

What did I miss?

--
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com

"Mark Rae [MVP]" <ma**@markNOSPAMrae.netwrote in message
news:uf**************@TK2MSFTNGP04.phx.gbl...
"Jonathan Wood" <jw***@softcircuits.comwrote in message
news:O5**************@TK2MSFTNGP05.phx.gbl...
>>With the solution I gave you, none of the dynamic form is rendered to
the client at all - that's the beauty of it. It's built up server-side,
and then redirected server-side. The first thing the client sees is the
response from the remote server...

Then why did I see the generated <formpage flash in my browser before
being redirected. (At least, in your original version of the code.)

No idea...
--
Mark Rae
ASP.NET MVP
http://www.markrae.net
Nov 4 '07 #15

"Jonathan Wood" <jw***@softcircuits.comwrote in message
news:O5**************@TK2MSFTNGP05.phx.gbl...
Mark,
>With the solution I gave you, none of the dynamic form is rendered to the
client at all - that's the beauty of it. It's built up server-side, and
then redirected server-side. The first thing the client sees is the
response from the remote server...

Then why did I see the generated <formpage flash in my browser before
being redirected. (At least, in your original version of the code.)
if I recall Mark's code, it was a series of Response.Write(...) statements
that would have been processed by the client browser, albeit with no client
content to display ... I understand Mark's statement that it's "built up
server-side" but I don't understand his comment that it's "redirected
server-side" .... the client gets <form... </formblock and *it* requests
the page in the action attribute ... it should happen quickly but to me,
this is happening on the client side, not the server .... where is the
output of those Response.Write statements going if not to the client?

Nov 4 '07 #16
Yes, that's how I saw it too and I tried it.

--
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com
"Barrie Wilson" <bw*****@nowhere.comwrote in message
news:13*************@corp.supernews.com...
>
"Jonathan Wood" <jw***@softcircuits.comwrote in message
news:O5**************@TK2MSFTNGP05.phx.gbl...
>Mark,
>>With the solution I gave you, none of the dynamic form is rendered to
the client at all - that's the beauty of it. It's built up server-side,
and then redirected server-side. The first thing the client sees is the
response from the remote server...

Then why did I see the generated <formpage flash in my browser before
being redirected. (At least, in your original version of the code.)

if I recall Mark's code, it was a series of Response.Write(...) statements
that would have been processed by the client browser, albeit with no
client content to display ... I understand Mark's statement that it's
"built up server-side" but I don't understand his comment that it's
"redirected server-side" .... the client gets <form... </formblock and
*it* requests the page in the action attribute ... it should happen
quickly but to me, this is happening on the client side, not the server
.... where is the output of those Response.Write statements going if not
to the client?


Nov 4 '07 #17
I'm unable to tell what you are doing there. When I hover over the Make
Payment button, it shows the PayPal Website in the status bar. I was under
the impression that, if the button was posting back to the server, it would
not show that. I can only imagine that you are posting data somehow as a
dollar amount appears on the PayPal page. But I'm not familiar with this
enough to understand what I'm seeing.

--
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com

"Mark Rae [MVP]" <ma**@markNOSPAMrae.netwrote in message
news:%2****************@TK2MSFTNGP05.phx.gbl...
"Jonathan Wood" <jw***@softcircuits.comwrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
>Then why when I said "Other than the annoyance of having the page flash
before being redirected, it does indeed appear to work," you replied
"There are all sorts of ways round that..."

What did I miss?

Here's an example of it working with no page flash:

1) http://www.sanctuaryrig.co.uk

2) Click the logo to enter the site
(Yes, that's me with my other "hat" on - sorry for the self-promotion, but
it's the only example of this that I have on the public Internet...)

3) Click Merchandise

4) Click Add to cart

5) Click View Cart

6) Select a delivery location

7) Click Proceed to checkout

8) Click Make payment - this just redirects to PayPal - you don't have to
proceed any further than that if you don't want to... ;-)
--
Mark Rae
ASP.NET MVP
http://www.markrae.net
Nov 4 '07 #18
In fact, if I implement the code you originally posted as a server-side
handler, and I click the button and get redirected to another site, and I
click the Back button, I go back to the form that redirected me and I get
redirected again.

--
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com

"Mark Rae [MVP]" <ma**@markNOSPAMrae.netwrote in message
news:%2****************@TK2MSFTNGP05.phx.gbl...
"Jonathan Wood" <jw***@softcircuits.comwrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
>Then why when I said "Other than the annoyance of having the page flash
before being redirected, it does indeed appear to work," you replied
"There are all sorts of ways round that..."

What did I miss?

Here's an example of it working with no page flash:

1) http://www.sanctuaryrig.co.uk

2) Click the logo to enter the site
(Yes, that's me with my other "hat" on - sorry for the self-promotion, but
it's the only example of this that I have on the public Internet...)

3) Click Merchandise

4) Click Add to cart

5) Click View Cart

6) Select a delivery location

7) Click Proceed to checkout

8) Click Make payment - this just redirects to PayPal - you don't have to
proceed any further than that if you don't want to... ;-)
--
Mark Rae
ASP.NET MVP
http://www.markrae.net
Nov 4 '07 #19
"Jonathan Wood" <jw***@softcircuits.comwrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
Then why when I said "Other than the annoyance of having the page flash
before being redirected, it does indeed appear to work," you replied
"There are all sorts of ways round that..."

What did I miss?
Here's an example of it working with no page flash:

1) http://www.sanctuaryrig.co.uk

2) Click the logo to enter the site
(Yes, that's me with my other "hat" on - sorry for the self-promotion, but
it's the only example of this that I have on the public Internet...)

3) Click Merchandise

4) Click Add to cart

5) Click View Cart

6) Select a delivery location

7) Click Proceed to checkout

8) Click Make payment - this just redirects to PayPal - you don't have to
proceed any further than that if you don't want to... ;-)
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Nov 4 '07 #20

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: StinkFinger | last post by:
Hello all, I am working on some simple pages that pass non-critical information (i.e. no passwords, usernames, etc.) to and from different pages. Currently, I am using FORMs w/the POST method. I...
111
by: JKop | last post by:
Okay here we go, I feel it's about time people conversed about the bullshit aspects of C++ (including the bullshit stuff brought forward from C). I'll begin with a few of my own grievances: 1)...
15
by: Robert Swan | last post by:
I'd like to know why the following program outputs 1, and not 0. #include <iostream> class a { int v; public: a():v(0){} a& operator++(int) { v++;
4
by: Vinayak | last post by:
Dear Members I'm new here. Please permit me to ask some newbie question I'm from a non-profit organization, working for gender equality. We wish to get a small message across to sister blogs...
8
by: Angel Tsankov | last post by:
Should pre/post increment/decrement return const or non-const? What about other functions?
0
by: molcaleviATyahoogroupsDOTcom | last post by:
KO mafia CFR ILLUMINATI ! Global Democracy TRIVOLUZIONE ARTSENU COLD FUSION W post OPEC ! B '' H _ KO mafia ! Global Democracy ARTSENU & Fusione Fredda = TRIVOLUZIONE
0
by: molcaleviATyahoogroupsDOTcom | last post by:
KO mafia CFR ILLUMINATI ! Global Democracy TRIVOLUZIONE ARTSENU COLD FUSION W post OPEC ! B '' H _ KO mafia ! Global Democracy ARTSENU & Fusione Fredda = TRIVOLUZIONE W post OPEC ! ! !
0
by: molcaleviATyahoogroupsDOTcom | last post by:
KO mafia CFR ILLUMINATI ! Global Democracy TRIVOLUZIONE ARTSENU COLD FUSION W post OPEC ! B '' H _ KO mafia ! Global Democracy ARTSENU & Fusione Fredda = TRIVOLUZIONE W post OPEC ! ! !
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.