动作控制器不发布所有变量

时间:2017-11-23 20:32:23

标签: c# asp.net-mvc http-post

我通过我的ASP.NET MVC 5控制器的操作发布了一些值,但唯一没有发布的变量是最后一个变量,它始终是最后一个未发布的变量。

这是代码:

transaction = (Transaction) Session["transaction"];
string affilie = ConfigurationManager.AppSettings["affilie"];
//db.transactions.Add(transaction);
//db.SaveChanges();
string refer = transaction.orderNumber;
ASCIIEncoding encoding = new ASCIIEncoding();
string data = string.Format("affilie={0} &Devise={1} &Montant={2} &refer={3}",affilie, transaction.currency,transaction.amount,refer);

byte[] bytes = encoding.GetBytes(data);
HttpWebRequest httpRequest = (HttpWebRequest)WebRequest.Create("http://localhost:22962/Payment/getData");
httpRequest.Method = "POST";
httpRequest.ContentType = "application/x-www-form-urlencoded";
httpRequest.ContentLength = bytes.Length;
using (Stream stream = httpRequest.GetRequestStream())
{
    stream.Write(bytes, 0, bytes.Length);
    stream.Close();
}

0 个答案:

没有答案