Convert GET to POST and Server.Transfer

C

CCY

Hi,

Is there a way to convert GET/QueryString to POST/Form when transfer
pages using Server.Transfer()?

For example,

1. page 1 url: http://domain/page1.aspx?name1=value1
2. page 2 url: http://domain/page2.aspx

I have no access to page2.aspx and it is coded to only handle POST
request. I also can't change page1.aspx to use POST, it must be using
GET.

Given above condition, when I call Server.Transfer("/page2.aspx")
inside page1.aspx, how do I pass the name1=value1 to page2.aspx?

Thanks in advance.

CCY
 
K

Keith Patrick

I've spent days trying out several different solutions to this problem. In
1.1, I never found a really satisfactory one outside programmatically
placing hidden text fields in your form. What I figured would work -
manually creating an HttpWebRequest and convert all query string values into
header values for a manual post - does not work, as there is only 1 request
thread per user, so your app will hang trying to spawn off the 2nd request
thread from the first. There's also using the Context to transfer the
values, but they won't survive a browser refresh. You could use ViewState,
but you need to stick with postbacks only, and if you go that route, you
might as well just interact with the controls themselves rather than futz
with viewstate.
Only thing I can really say to "fix" this (within 1.1; 2.0 gives better
control via Page.Form[]) is to change how you go from page-to-page, using
PostBacks and treating your app like a persistant page navigation app
instead of performing redirects or transfers. By going with that model, you
access all POSTed values via their ASP.Net control abstractions instead of
dealing with headers and key/value pairs (BTW: even in 1.1, you can still
grab these POSTed values by referencing their control names, as their
underlying header values are still in the request)
 
C

CCY

Thanks Keith, but I couldn't go with your suggestion because I have no
access to page2, and page1 is called with GET. I can't change these 2
conditions. I need to pass the "QueryString" received by page1 to
page2, and page2 must read it from "Form".


CCY
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,016
Latest member
TatianaCha

Latest Threads

Top