C++ Builder6 运行通过asp.net能取得数据:
String tmpStr="Type=1&DeviceInfo=[("+Edit1->Text+"|"+Edit2->Text+")]";
TIdHTTP *TIdHTTP1=new TIdHTTP(this);
TStrings  *Source=new  TStringList();
TStringStream  *stream=new  TStringStream("");
Source->Add(tmpStr);
TIdHTTP1->Post("http://localhost/RemoteAddDevice.aspx",Source,stream);
Memo1->Text=stream->DataString;Delphi7,asp.net却不能取得数据:
var
  Str,tmpStr:String;
  tmpStrings:Source;
  LResponse: stream;
begin
      tmpStr:='Type=1&DeviceInfo=[('+Trim(Name.Text)+'|'+Trim(Pass.Text)+')]';
      Source:=TStringlist.Create;
      Source.Add(tmpStr);
      stream:= TStringStream.Create('');
      MainForm.IdHTTP1.Post('http://localhost/RemoteAddDevice.aspx',Source,stream);
      Memo1.Text=:=stream.DataString;
end;头痛头痛啊~!~~~>_<~~~~

解决方案 »

  1.   

    看起来好象没什么问题,难道是编译器的问题,还是Indy版本不同造成的?
      

  2.   

    var
      Str,tmpStr:String;
      tmpStrings:Source;
      LResponse: stream;这是你的代码么?
      

  3.   

    上面的变量声明打错了!呵呵!实现问题词跟变量声明无关!:)
    在Delphi8下:
    var
      tmpStr:String;
      Source,stream:TStringStream;
      IdHTTP1:TIdHTTP;
    begin
        tmpStr:='Type=1&DeviceInfo=[(中文字|testpwd)]';
          IdHTTP1:=TIdHTTP.Create(Form1);
          Source:= TStringStream.Create(tmpStr);
          stream:= TStringStream.Create('');
          IdHTTP1.Post('http://localhost/WebApplication1/WebForm1.aspx',Source,stream);
          Memo1.Text:=stream.DataString;WebForm1.aspx为:
    Response.Write("Received"+Request.TotalBytes.ToString()+"TYPE:"+Request.Form["Type"]);-----------------------------------
    运行用结果Request.TotalBytes居然为0!!!!!Delphi得回的结果是:"Received0TYPE:"
    Post函数好像不起作用?!!!!!!
    求教啊!:(
      

  4.   

    procedure TForm1.Button4Click(Sender: TObject);
    var
      postList: TStrings;
    begin
      Edit1.Text := 'http://community.csdn.net/expert/forum.asp';
      postList := TStringList.Create;
      try
        postList.Add('login_name=cronuz');
        postList.Add('password=***');
        memo1.Lines.Text := IdHTTP1.Post( Edit1.Text, postList );
      finally
        Edit1.Text := IdHTTP1.Response.Server+': '+IdHTTP1.Response.ResponseText;
        postList.Free;
      end;
    end;説明:把在CSDN的登録名改成你的试试看
      

  5.   

    Indy版本不一致?建议用最新的Indy9.0.16
    在AtoZed.Com的http://lysoft.7u7.net
      

  6.   

    to ly_liuyang(Liu Yang):
    感谢兄弟,但AtoZed.Com的Indy是正版的,要购买的!兄弟不是要我买正版吧?!我无钱啊!
    :(
    (小声说:有盗版的吗?:))
      

  7.   

    老大
    Indy是免费的!AtoZed.com的Indy是免费下载的,填入垃圾资料就可以了进入下载页我才去没多久,没这么快变收费吧?你先认真看清楚吧http://lysoft.7u7.net
      

  8.   

    刚刚看到IndyPlus!感谢!我试试行不行先!)
      

  9.   

    好像的确是Indy的版本问题,今天有事不能仔细测试,明天再测试一下,然后结贴!
    感谢各位帮助!:)