How Do I Post and then redirect to an external URL from ASP.Net?

前端 未结 6 902
说谎
说谎 2021-02-05 01:23

ASP.NET server-side controls postback to their own page. This makes cases where you want to redirect a user to an external page, but need to post to that page for some reason (

6条回答
  •  春和景丽
    2021-02-05 01:57

    I have done this by rendering a form that auto-posts (using JavaScript) to the desired remote URL - gather whatever information you need for the post in the web form's postback and then build the HTML for the remote-posting form and render it back to the client.

    I built a utility class for this that contains the remote URL and a collection of name/value pairs for the form.

    Cross-page posting will work if you own both of the pages involved, but not if you need to post to another site (PayPal, for example).

提交回复
热议问题