Asp.net 使用“代码隐藏”中的Post方法重定向到另一个页面
我想实现一个支付服务。我将在代码隐藏中创建一些值,然后使用post方法将这些值发布到支付网关,用户必须重定向到该页面 我不能使用表单操作,因为我必须创建一些值,并在db中的代码隐藏中保存一些内容 我如何实现这一点? 如果我能将数据发布到我的应用程序的另一个页面,并能通过编程提交该页面,这可能会对我有所帮助 谢谢 看看这张海报Asp.net 使用“代码隐藏”中的Post方法重定向到另一个页面,asp.net,code-behind,Asp.net,Code Behind,我想实现一个支付服务。我将在代码隐藏中创建一些值,然后使用post方法将这些值发布到支付网关,用户必须重定向到该页面 我不能使用表单操作,因为我必须创建一些值,并在db中的代码隐藏中保存一些内容 我如何实现这一点? 如果我能将数据发布到我的应用程序的另一个页面,并能通过编程提交该页面,这可能会对我有所帮助 谢谢 看看这张海报 我正在针对相同的问题实施cashu,但在响应期间。写入时显示以下错误:基础连接已关闭:连接意外关闭。我还需要将它重定向到cashu页面,这里的“新页面”是什么?所以这个
string url = "3rd Party Url";
StringBuilder postData = new StringBuilder();
postData.Append("first_name=" + HttpUtility.UrlEncode(txtFirstName.Text) + "&");
postData.Append("last_name=" + HttpUtility.UrlEncode(txtLastName.Text));
//ETC for all Form Elements
// Now to Send Data.
StreamWriter writer = null;
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded";
request.ContentLength = postData.ToString().Length;
try
{
writer = new StreamWriter(request.GetRequestStream());
writer.Write(postData.ToString());
}
finally
{
if (writer != null)
writer.Close();
}
Response.Redirect("NewPage");