0

I'm integrating CashU Payment gateway.

I need to Post some data using POST method. then I want to redirect to payment gateway site.

I have done so far

 [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;

        }

My ExecutePost method is returing a Html page string in string formate. But I want to redirect on payment gateway site.

Programmer
  • 398
  • 1
  • 9
  • 33
  • please some one help me . – Programmer Jul 11 '15 at 19:27
  • 1
    Is [this SO question](http://stackoverflow.com/questions/9739170/how-to-redirect-to-external-url-from-c-sharp-controller) any help? It shows you how to redirect to an external url from an MVC controller using the [Redirect](https://msdn.microsoft.com/en-us/library/system.web.mvc.controller.redirect.aspx) function. – Jason Evans Jul 11 '15 at 20:18
  • @JasonEvans: but it won't make POST redirect. – Programmer Jul 12 '15 at 14:23

1 Answers1

0

you can use

return Redirect("URl");

to redirect to a different url

michael berezin
  • 1,146
  • 7
  • 8