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

前端 未结 6 888
说谎
说谎 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 02:11

    I would do the form post in your code behind using HttpWebRequest class. Here is a good helper class to get your started:

    http://geekswithblogs.net/rakker/archive/2006/04/21/76044.aspx

    From there, you can just do a Response.Redirect, or perhaps you need to vary your action based on the outcome of the post (if there was an error, display it to the user or whatever). I think you already had the answer in your question to be honest - sounds like you think it is a post OR redirect when in reality you can do them both from your code behind.

提交回复
热议问题