【问题标题】:Adding another variable to PayPal URL query string向 PayPal URL 查询字符串添加另一个变量
【发布时间】:2016-03-21 14:46:57
【问题描述】:

我只是在学习.. 谁能告诉我在设置这个贝宝参数字符串时如何添加变量 p=1。这就是 mo 的情况,它工作得很好。我只需要添加 p=1 但我认为语法一直是错误的。谢谢。

paypalParameterString.Append("return=http://examplesite.com/accounts.aspx?page=" & Request.QueryString("page") & "&")

【问题讨论】:

    标签: asp.net vb.net paypal


    【解决方案1】:

    如果要向 url 添加更多参数,则需要在参数之间添加 & 符号。例如

    http://examplesite.com/accounts.aspx?parameter1=foo&parameter2=bar
    

    所以如果你想在上面提到的url中添加值为1的参数p,它应该是这样的

    paypalParameterString.Append("return=http://examplesite.com/accounts.aspx?page=" & Request.QueryString("page") & "&p=1")
    

    如果您不想硬编码值 1

    paypalParameterString.Append("return=http://examplesite.com/accounts.aspx?page=" & Request.QueryString("page") & "&p=" & value)
    

    【讨论】:

    【解决方案2】:

    您需要encode 您的网址,因为它是参数的一部分。

    把你的网址放在一个字符串变量中

    url = "http://examplesite.com/accounts.aspx?page=" & Request.QueryString("page") & "&p=1"
    

    然后通过确保对其进行编码将其添加为参数

    paypalParameterString.Append("return=" & Server.UrlEncode(url))
    

    这将(例如)将 & 转换为 %26

    注意:如果需要,您可以将所有内容放在一行中

    paypalParameterString.Append(Server.UrlEncode("return=http://examplesite.com/accounts.aspx?page=" & Request.QueryString("page") & "&p=1"))
    

    【讨论】:

    • 试过这个但得到:字符无效错误:-(
    • 我需要使用“url”吗?我将其更改为“myurl”,因为我的“url”进一步向下并且它导致了问题?
    • @Eggybread 这只是一个示例变量,你可以随意命名或将整个url直接放在UrlEncode中
    • 像这样再次尝试.. paypalParameterString.Append("return=" & Server.UrlEncode("examplesite.com/accounts.aspx?page=" & Request.QueryString("page") & "&p=1"))仍然出现 Character is not valid 错误感谢您的帮助。
    猜你喜欢
    • 2023-03-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-12-03
    • 2013-01-10
    • 2012-01-02
    • 1970-01-01
    相关资源
    最近更新 更多