我无法将发布数据发送到其他服务器

时间:2011-05-17 23:24:40

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

这是我现在的代码:

  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>";

2 个答案:

答案 0 :(得分:1)

以下是使用c#发布到PHP的网络示例:

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

答案 1 :(得分:1)

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

检查异常。

相关问题