use HttpWebRequest/HttpWebResponse class, or try
catch(WebException ex)
{HttpWebResponse res  = (HttpWebResponse)ex.Response;
        MessageBox.Show((int)res.StatusCode);
}

解决方案 »

  1.   

    step1:use HttpWebRequest class to request,and use HttpWebResponse get the response.if you read the response, you can get the information including what did in the Page_load function.step2: if you want to fill a textbox or click a button and etc..  in this page, you can repalce the response with the Message,and use HttpWebRequest class to post it to the server.The server will get what in the textbox or do the Onclick function.Message: you can use sniffer to catch the postbag and get what in it,usually with a '&' and the webcontrol name or id.It is a format of ASPX post. 
      

  2.   

    以下代码是FTP上传完了向一个指定的页面发送请求,填写三个textbox,click一个button的class:
    public class FtpMessage
    {
    private string m_fileName;
    private string m_host;
    private string aspValue; public FtpMessage(string fileName,string hostUrl)
    {
    //
    // TODO: 在此处添加构造函数逻辑
    //
    m_fileName = fileName;
    m_host = hostUrl;
    } public bool SendCompleteMessage(string user,string password)
    {
    bool isSendMessageSuccess = false;
    HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://"+m_host);
    //得到网页。
    WebResponse response = null;
    response = request.GetResponse();
    Stream readStream = response.GetResponseStream();
    StreamReader sr = new StreamReader(readStream,Encoding.GetEncoding("utf-8"));
    string content = "";
    int index = -1;
    //寻找数据
    while (index < 0 && content != null) 
    {
    content = sr.ReadLine();
    index = content.IndexOf("name=\"__VIEWSTATE\" value=\"",0);
    }
    index += 26;
    int endIndex = content.LastIndexOf("\"");
    //形成目标数据。
    if (index > 26 && endIndex > index)
    {
    aspValue = content.Substring(index,endIndex-index);
    StringBuilder tempData = new StringBuilder();
    tempData.Append("__VIEWSTATE=");
    tempData.Append(HttpUtility.UrlEncode(aspValue));
    tempData.Append("&TextBoxFileName=");
    tempData.Append("(content1)");
    tempData.Append("&TextBoxUser=");
    tempData.Append("(content2)");
    tempData.Append("&TextBoxPassword=");
    tempData.Append("(content3)");
    tempData.Append("&ButtonForData=");
    tempData.Append(HttpUtility.UrlEncode("Message"));
    aspValue = tempData.ToString();
    } string content1 = m_fileName;
    string content2 = user;
    string content3 = password;
    WebResponse response1 = null;
    //替换预传送的数据。
    string tempData1 = aspValue.Replace("(content1)",HttpUtility.UrlEncode(content1));
    string tempData2 = tempData1.Replace("(content2)",HttpUtility.UrlEncode(content2));
    string tempData3 = tempData2.Replace("(content3)",HttpUtility.UrlEncode(content3));
    byte [] postData = Encoding.UTF8.GetBytes(tempData3.ToString()); HttpWebRequest request1 = (HttpWebRequest)WebRequest.Create("http://"+m_host); //设定工作属性。
    request1.Method = "POST";
    request1.ContentType = "application/x-www-form-urlencoded";
    request1.ContentLength = postData.Length;

    //上传数据。
    Stream writeStream = request1.GetRequestStream();
    writeStream.Write(postData,0,postData.Length);
    writeStream.Close();

    //下载网页。
    string serverMessage = "";
    try
    {
    response1 = request1.GetResponse();

    Stream readStream1 = response1.GetResponseStream();
    int i = 1024;
    byte[] hehe = new byte[i];
    readStream1.Read(hehe,0,i);
    readStream1.Close();
    StringBuilder hehe1 = new StringBuilder();
    for(int j=658;j<662;j++)
    {
    hehe1.Append((char)hehe[j]);
    }
    serverMessage = hehe1.ToString(); }
    catch(Exception E)
    {
    string tempError = E.Message;
    }
    if(serverMessage == "true")
    {
    isSendMessageSuccess = true;
    }
    return isSendMessageSuccess;
    }
    }
      

  3.   

    希望isaacyh(Ipig)能向那个五星学习一下,只给出对贴主有用的信息,而不是一大堆无关的代码或是转载.