开发者

I can't send post data to another server

this is my code right now:

  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("htt开发者_如何转开发ps://juzcode.com/post.php", postdata) ' exception here
        Response.Write(Encoding.ASCII.GetString(bytes))


    End Sub

However I'm getting exception "Unable to connect to the remote server". Am I doing something wrong?

Btw this is the code for http://juzcode.com/post.php:

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


Here is an example on the web of using c# to post to PHP:

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


Put your code into a Try / Catch you may be trying to fight a loosing battle behind a corporate firewall.

Check the exception.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜