一个简单的asp.net程序
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default4.aspx.cs" Inherits="Server_Default4" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>无标题页</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>    
        <input id="id" type="text" runat="server"/><br />
        <input id="pwd" type="text" runat="server"/></div>
    <asp:Button ID="Submit" runat="server" onclick="Submit_Click" Text="Submit" />
    </form>
</body>
</html>
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;public partial class Server_Default4 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
      //  
    }
    protected void Submit_Click(object sender, EventArgs e)
    {
        Response.Write("id=" + id.Value);
        Response.Write("<br>");
        Response.Write("id=" + pwd.Value);
    }
}
procedure TForm1.Button1Click(Sender: TObject);
var
  S: TIdMultiPartFormDataStream;
begin
  S := TIdMultiPartFormDataStream.Create;
  try
    S.AddFormField('user', '123456');
    S.AddFormField('pwd', 'test');
    Memo1.Text := IdHTTP1.Post('http://localhost/server/default4.aspx',S);
  finally
    S.Free;
  end;
end;请问上面delphi程序怎么修改才能触发submit呢?

解决方案 »

  1.   

    只需要传入URL参数也不正确?procedure TForm1.Button1Click(Sender: TObject);
    var
      S: TStringList;
    begin
      S := TStringList.Create;
      try
        S.Clear;
        S.Add('id=123456');
        S.Add('pwd=123456');
        IDHttp1.HandleRedirects := True;
        IDHttp1.request.contenttype:='application/x-www-form-urlencoded';
        Memo1.Text:= IDHttp1.Post('http://localhost/test.aspx',S);
      finally
        S.Free;
      end;
    end;test.aspx
        protected void Page_Load(object sender, EventArgs e)
        {
            string id = Request.QueryString["id"];
            string pwd = Request.QueryString["pwd"];
            Response.Write("id=" + id + "\r\n");
            Response.Write("pwd=" + pwd + "\r\n");
        }