public ActionResult QueryDR([Bind(Include = "vpc_MerchTxnRef, vpc_User, vpc_Password")] string vpc_MerchTxnRef, string vpc_User, string vpc_Password) { ViewBag.QueryDRStatus = "none"; if (string.IsNullOrEmpty(vpc_MerchTxnRef) || string.IsNullOrEmpty(vpc_User) || string.IsNullOrEmpty(vpc_Password)) { return(View(new QueryDRResponse())); } var VPC_URL = "https://migs.mastercard.com.au/vpcdps"; var paymentRequest = new PaymentRequest { AccessCode = ConfigurationManager.AppSettings["MigsAccessCode"], MerchTxnRef = vpc_MerchTxnRef, User = vpc_User, Password = vpc_Password }; var transactionData = paymentRequest.GetQueryDRParameters().OrderBy(t => t.Key, new VPCStringComparer()).ToList(); var redirectUrl = VPC_URL + "?" + string.Join("&", transactionData.Select(item => HttpUtility.UrlEncode(item.Key) + "=" + HttpUtility.UrlEncode(item.Value))); HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(redirectUrl); req.Method = "POST"; var response = (HttpWebResponse)req.GetResponse(); var responseString = new StreamReader(response.GetResponseStream()).ReadToEnd(); var queryString = responseString.Split('&').ToDictionary(x => x.Split('=')[0], x => x.Split('=')[1]); ViewBag.QueryDRStatus = ""; QueryDRResponse model = new QueryDRResponse(); model.message = queryString["vpc_Message"]; model.DRExists = queryString["vpc_DRExists"]; model.TxnResponseCode = queryString["vpc_TxnResponseCode"]; return(View(model)); }