问题描述
我使用WebForms和我需要创建和 POST
一个HTTP 格式
来支付网关一我的客户。我使用的是显示在母版的用户控件,但他们已经有一个现有的<形式>
在页面上,所以我pretty确定我不能添加其他。
I'm using webforms and I need to create and POST
an http form
to a payment gateway for one of my clients. I'm using a user control that is displayed in a masterpage, however they already have an existing <form>
on the page, so I'm pretty sure I cannot add another.
什么是最好的实践方法来创建,并从code后面在C#中发布形式?目前,我有以下几点:
What is the best practice method to create and post a form in C# from the code behind? Currently I have the following:
var nvc = new System.Collections.Specialized.NameValueCollection
{
{"EWAY_ACCESSCODE", ewayResponse.AccessCode},
{"EWAY_CARDNAME", txtCcName.Text},
{"EWAY_CARDNUMBER", txtCcNumber.Text},
{"EWAY_CARDEXPIRYMONTH", ddlCcExpMonth.SelectedValue},
{"EWAY_CARDEXPIRYYEAR", ddlCcExpYear.SelectedValue},
{"EWAY_CARDCVN", txtCcv.Text}
};
var client = new WebClient();
client.UploadValues(ewayResponse.FormActionURL, nvc);
这样的工作,但有没有更好的/替代的方式来做到这一点?
推荐答案
除了previous建议:
Aside from the previous suggestion:
-
为什么不一个(简单)Button.PostbackUrl工作?
<asp:Button ID="externalPost" runat="server" PostBackUrl="http://www.somewhere.com/" Text="Post Somewhere" />
此外,假设这是你指的是,你正在做一个服务器端的POST,这对的 PCI合规性的(相对于从客户的直接形式邮寄/浏览器影响的支付网关)。
Also, assuming that's a payment gateway you're referring to, you're doing a server-side POST, which has implications on PCI Compliance (vs. a direct form post from client/browser).
Hth以上。
这篇关于创建并张贴在codebehind在C#形式的最佳方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!