【发布时间】:2015-07-11 18:48:58
【问题描述】:
我正在集成 CashU 支付网关。
我需要使用 POST 方法发布一些数据。然后我想重定向到支付网关站点。
到目前为止我已经完成了
[HttpPost]
public ActionResult Index(string getAmount)
{
// some more process
var getResponce = ExecutePost(getTokenCode);
}
private string ExecutePost(string tokenCode)
{
var cashuLink = ConfigurationManager.AppSettings["CashULink"].ToString();
HttpWebRequest webReq = (HttpWebRequest)WebRequest.Create(cashuLink);
var postData = "Transaction_Code="+tokenCode;
postData += "&test_mode=1";
var data = Encoding.ASCII.GetBytes(postData);
webReq.Method = "POST";
webReq.ContentType = "application/x-www-form-urlencoded";
webReq.ContentLength = data.Length;
using (var stream = webReq.GetRequestStream())
{
stream.Write(data, 0, data.Length);
}
var response = (HttpWebResponse)webReq.GetResponse();
var responseString = new StreamReader(response.GetResponseStream()).ReadToEnd();
return responseString;
}
我的 ExecutePost 方法正在返回字符串格式的 Html 页面字符串。但我想在支付网关网站上重定向。
【问题讨论】:
-
请有人帮帮我。
-
this SO question 有帮助吗?它向您展示了如何使用 Redirect 函数从 MVC 控制器重定向到外部 url。
-
@JasonEvans: 但它不会进行 POST 重定向。
标签: c# asp.net asp.net-mvc payment-gateway