【问题标题】:I can't send post data to another server我无法将发布数据发送到另一台服务器
【发布时间】:2011-05-17 23:24:39
【问题描述】:

这是我现在的代码:

  Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        System.Net.ServicePointManager.Expect100Continue = False
        Dim client = New System.Net.WebClient()
        Dim postdata = New System.Collections.Specialized.NameValueCollection
        postdata.Add("username", "qweqwe")
        postdata.Add("password", "asdasd")
        Dim bytes = client.UploadValues("https://juzcode.com/post.php", postdata) ' exception here
        Response.Write(Encoding.ASCII.GetString(bytes))


    End Sub

但是我收到异常“无法连接到远程服务器”。我做错了吗?

顺便说一句,这是http://juzcode.com/post.php的代码:

<?php if($_POST["username"]==="qweqwe" && $_POST["password"]==="asdasd")echo "<b>success</b>";else echo "<i>failed</i>";

【问题讨论】:

  • juzcode.com/post.php 似乎无法连接 - 我的浏览器在漫长的等待后愉快地超时了。
  • @Will A 出于某种原因,我的 Firefox 也这样做了。但它在 Chrome 上运行良好。我不知道为什么,请参阅我编辑的问题

标签: asp.net vb.net web-services


【解决方案1】:

下面是网上使用c#发布到PHP的例子:

http://blog.brezovsky.net/en-text-1.html

【讨论】:

    【解决方案2】:

    将您的代码放入 Try / Catch 中,您可能正试图在公司防火墙后面打一场失败的战斗。

    检查异常。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-12-03
      • 1970-01-01
      • 2021-10-22
      • 1970-01-01
      • 2012-03-10
      • 2019-01-24
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多