I want to do something similar to what happens when you click an asp.net button that has a PostBackURL set. I've tried Server.Transfer
but the URL doesn't change (which is something I want). Is there a better way to do this, or alternatively is there a way to make Server.Transfer display the correct URL?
views:
43answers:
2Try Response.Redirect
UPDATE:
You can't do a proper postback from codebehind to my knowledge I'm afraid
See:
Cross-Page Posting in ASP.NET Web Pages
How to: Post ASP.NET Web Pages to a Different Page
asp:Button
ID="Button1"
PostBackUrl="~/TargetPage.aspx"
runat="server"
Text="Submit" />
Edit: You could also construct a HTTP POST in the codebehind and send it to the target page then write the response out to the browser. This won't change the URL in the brower's address bar to the actual page that the data was POSTed to. What you can do depends on what control you have. Is the page that is POSTed to under your control? Do it contain any text/data that is specific to what is POSTed to it? You could do the POST and then redirect/transfer to the target page but that may or may not display the result of the POST correctly.
How to use HttpWebRequest to send POST request to another web server may be of some help if you decide to go this way.