如何使用 mvc 3 将 http post 表单参数发送到 worldpay(使用 MVC 与 Worlpay 集成)

发布于 2024-11-17 23:57:34 字数 1093 浏览 2 评论 0原文

任何人都可以帮助我使用 mvc http post 将参数传递到 worldpay 网站,下面是我在 google 上找到的示例,该示例正在视图上运行,但我想通过 http[post] 操作控制器传递参数:

<form method="post" action="https://secure.wp3.rbsworldpay.com/wcc/purchase" id="frmWorldPay">
                    <input type="hidden" name="instId" value="1" />
                    <input type="hidden" name="cartId" value="<%: Model.CardID %>" />
                    <input type="hidden" name="currency" value="GBP" />
                    <input type="hidden" name="amount" value="<%= Model.Cost%> " />
                    <input type="hidden" name="desc" value="<%: ViewBag.Name %> track day" />
                    <input type="hidden" name="email" value="<%: Model.aspnet_Users.aspnet_Membership.Email %>" />
                    <input type="hidden" name="name" value="<%: Model.FullName %>" />
                    <input type="hidden" name="address" value="<%: Model.Address %>" />

                    <input type="hidden" name="testMode" value="100" />

Can any one help me in passing the parameters to the worldpay site using mvc http post , below is the example which i found on google , the example is working on view , but I want to pass the parameters through http[post] action controller :

<form method="post" action="https://secure.wp3.rbsworldpay.com/wcc/purchase" id="frmWorldPay">
                    <input type="hidden" name="instId" value="1" />
                    <input type="hidden" name="cartId" value="<%: Model.CardID %>" />
                    <input type="hidden" name="currency" value="GBP" />
                    <input type="hidden" name="amount" value="<%= Model.Cost%> " />
                    <input type="hidden" name="desc" value="<%: ViewBag.Name %> track day" />
                    <input type="hidden" name="email" value="<%: Model.aspnet_Users.aspnet_Membership.Email %>" />
                    <input type="hidden" name="name" value="<%: Model.FullName %>" />
                    <input type="hidden" name="address" value="<%: Model.Address %>" />

                    <input type="hidden" name="testMode" value="100" />

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

迟到的我 2024-11-24 23:57:34

查看 System.Net.WebClient

此外,这个问题可能会进一步帮助您。

编辑

您应该点击我发布的链接。在那里你可以找到这个示例代码

using System;
using System.Text;
using System.Net;
using System.Collections.Specialized;
//...

string url = "http://www.amazon.co.uk/exec/obidos/search-handle-form";
NameValueCollection formData = new NameValueCollection();
formData["field-keywords"] = "Harry Potter";
// add more form field / values here

WebClient webClient = new WebClient();
byte[] responseBytes = webClient.UploadValues(url, "POST", formData);
string response = Encoding.UTF8.GetString(responseBytes);

Console.WriteLine(response);

Have a look at System.Net.WebClient.

Also this question on SO may help you further.

edit

You should follow the links I posted. There you find i.e. this example code

using System;
using System.Text;
using System.Net;
using System.Collections.Specialized;
//...

string url = "http://www.amazon.co.uk/exec/obidos/search-handle-form";
NameValueCollection formData = new NameValueCollection();
formData["field-keywords"] = "Harry Potter";
// add more form field / values here

WebClient webClient = new WebClient();
byte[] responseBytes = webClient.UploadValues(url, "POST", formData);
string response = Encoding.UTF8.GetString(responseBytes);

Console.WriteLine(response);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文