问题描述
我正在使用C#中的webbrowser控件为桌面应用程序通过网关运行信用卡。
I am using the webbrowser control in C# for our desktop application to run a credit card through a gateway.
简单来说,我正在加载页面格式如下:
Simply, I'm loading the page on the load of the form:
public Form1()
{
InitializeComponent();
webBrowser1.Url = new Uri("https://paymentgateway.com/hosted.aspx?" +
"Username=dddd" +
"&Password=dddd" +
"&MerchantKey=5159" +
"&BillingAddress1=123 some street" +
"&BillingCity=Somewhere" +
"&BillingState=SC" +
"&BillingZip=39399" +
"&CustomerName=me" +
"&Amount=392.00" +
"&InvNum=123567" +
"&AccountNumber=0133333" +
"&CustomerId=0199999");
}
(出于安全原因更改了所有引用)
(all references changed for security reasons)
页面看起来像这样:
我的问题是,一旦单击处理按钮后,如何获取响应,然后关闭表格?我需要知道它是否已被批准,以及从那时起的其余信息。
My question is, how do I grab the response once the Process button has been clicked and then close out the form? I need to know if it was approved and the rest of the information from that point.
我无法控制按钮,因此我不确定如何捕获响应。
I don't have control over the button so I'm not sure how to capture the response.
再次感谢!
推荐答案
您需要订阅事件,然后通过Document,DocumentText或DocumentStream处理响应。
It seems that you need to subscribe to the DocumentCompleted event and handle the response there via Document, DocumentText or DocumentStream.
然后,您将根据输出内容做出适当的反应。例如:
You would then react appropriately depending on what the output is. For example:
private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
HtmlDocument document = webBrowser1.Document;
//now use any of the methods exposed by HtmlDocument to parse the output
}
这篇关于捕获webBrowser控件响应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!