VB.NET - WebClient POST - 贝宝高级编码的痛苦 [英] VB.NET - WebClient POST - PayPal Advanced encoding pains

查看:184
本文介绍了VB.NET - WebClient POST - 贝宝高级编码的痛苦的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好我使用的是vb.NET。我的问题与ASP.NET有关。

我正在使用.NET中的WebClient向PayPal服务器进行POST。存在编码某些字符的问题。特别是电子邮件地址中的@符号。 PayPal工作人员告诉我,电子邮件正在被发布为name%40domain.com。 @已被换出%40



我已经通过多种方式更改了WebClient的编码,但没有任何帮助。 PayPal的技术人员说服务器可能与这种自动编码有关。我联系了我的域管理员,他们没有任何线索。



无论如何我可以停止此POST的编码并在电子邮件中发送@符号而不进行编码?



我将代码更改为UTF8的代码片段如下所示。我真的很想听听那些知道的人。 PayPal技术似乎无法继续下去。



我是否正确使用WebClient.encoding?因为无论我将其更改为什么,我都没有看到任何变化。

Hi I use vb.NET. My question is pertaining to ASP.NET.
I'm POSTing using the WebClient in .NET to PayPal servers. There is an issue where some characters are being encoded. Particularly the @ symbol within an email address. The PayPal staff are telling me that the eMail is being POSTed as "name%40domain.com". The @ has been swapped out for %40

I have changed the encoding of the WebClient in numerous ways but nothing has helped. The tech at PayPal says that the server might have something to do with this automatic encoding. I contacted my domain admin and they had no clue.

Is there anyways I can stop the encoding of this POST and send the @ symbol within the email without it being encoded?

A snippet of my code where I'm changing the encoding to UTF8 is shown below. I would really like to hear from those who know. PayPal tech doesn't seem to be able to go any further.

Am I even using the WebClient.encoding correctly? Because I have seen no change no matter what I change it to.

Dim collection As New NameValueCollection
collection.Add("EMAIL", "name@domain.com")

Dim wc As New WebClient()
wc.Encoding = System.Text.Encoding.UTF8
Dim response As Byte() = wc.UploadValues(cURL, "POST", collection)
wc.Dispose()

'I have also tried:

'wc.Encoding = System.Text.Encoding.GetEncoding("ISO-8859-1")
'wc.Encoding = System.Text.Encoding.ASCII
'wc.Encoding = System.Text.Encoding.Default





这是大约三到四天前开始的东西没有任何编码。



PS。我应该提一下,我使用PayPal托管的付款表单布局C并收到错误:

•某些必填信息缺失或不正确。请更正以下字段并重试。

•错误:请输入有效的电子邮件地址。



信用卡出现错误卡已提交。

当WebClient POST如上图所示,我收到RESULT = 0& RESPMSG = Approved



你会想到电子邮件将在初始POST时被拒绝,但事实并非如此。错误只显示我点击提交订单以在iFrame中发送CC号码。



谢谢,



This is something that just started about three to four days ago without any coding on my end.

"PS. I should mention that I am using PayPal hosted payment forms Layout "C" and am receiving error:
• Some required information is missing or incorrect. Please correct the fields below and try again.
• Error: Please enter a valid email address."

The error appears when the Credit card is submitted.
When the WebClient POST as shown above, I receive "RESULT=0&RESPMSG=Approved"

You would think the eMail would be rejected on the initial POST but it is not. The error only shows when I click on SUBMIT ORDER to send the CC numbers in the iFrame.

Thanks,

推荐答案

不确定它会有所帮助,但这是我用来向网站发布请求的方法,我有一个PHP脚本来接收请求并确实有字符编码的一些问题。



Not sure it will help but here is a method I use for posting requests to a site, I have a PHP script that picks up the request and did have a few problems with character encoding.

Dim myRequester As WebRequest

Dim postData As String = Uri.EscapeUriString("<the data to send>")
Dim byteArray As Byte() = Encoding.UTF8.GetBytes(postData)

myRequester = WebRequest.Create("<your site url>")
myRequester.Method = "POST"
myRequester.ContentType = "application/x-www-form-urlencoded"
myRequester.ContentLength = byteArray.Length

Dim dataStream As Stream = myRequester.GetRequestStream()
dataStream.Write(byteArray, 0, byteArray.Length)
dataStream.Close()

Try
  response = CType(myRequester.GetResponse(), HttpWebResponse)
Catch ex As Exception
  response = CType(ex, System.Net.WebException).Response
End Try

If Response.StatusCode = HttpStatusCode.OK Then ...


这篇关于VB.NET - WebClient POST - 贝宝高级编码的痛苦的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆