0
我正在集成CashU支付网关。使用HttpWebRequest c发布数据后重定向到Url#
我需要使用发布一些数据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方法returing字符串甲Html页面串完成。但是我想在支付网关站点上重定向。
请有人帮助我。 – Programmer
是[这是这个问题](http://stackoverflow.com/questions/9739170/how-to-redirect-to-external-url-from-c-sharp-controller)有帮助吗?它向您展示了如何使用[Redirect](https://msdn.microsoft.com/en-us/library/system.web.mvc.controller.redirect.aspx)函数从MVC控制器重定向到外部URL。 –
@JasonEvans:但它不会让POST重定向。 – Programmer