duanmibei1929 2012-08-23 06:37
浏览 50

在.NET中获取PHP脚本请求的响应

hey i am making an activation architecture in .net. I have written a script that posts the PHP variables, however, the PHP echos back a server response and i want to get that response back.

I have tried some code pieces but they don't work.

the sample php script is:

<?php

$name = $_POST['username'];

echo $name;

?>

i can't get the response, i.e. echo $name, i cant get it please help

my code is:

 Dim requestStream As Stream = request.GetRequestStream()
    requestStream.Write(postBuffer, 0, postBuffer.Length)


    Dim stream As Stream = request.GetResponse().GetResponseStream()

    Dim reader As New StreamReader(stream)

    Dim response As String

    Dim newStream As Stream = request.GetRequestStream()

    While response = reader.ReadLine()
        response += reader.ReadLine()
    End While



    Return response

    requestStream.Close()

thanks

  • 写回答

1条回答 默认 最新

  • dpi96151 2013-08-27 10:46
    关注

    You may want to check my Answer to this post. It's a bit more complicated than the answer you need, but it will solve your problem. The Second Example is what you want. But don't just copy it, you need the class and the reference too.

    Hope it helps.

    评论

报告相同问题?

悬赏问题

  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)