0

HttpWebRequest を使用して POST リクエストを送信しようとすると、フィドラーは GET を送信していることを示していますか? 私が間違っていることを見ることができるので、どんな助けも大歓迎です。

コード:

HttpWebRequest request = (HttpWebRequest)WebRequest.Create(LOGIN_API_BASE_URL);
        string postString = string.Format("api_email={0}&api_password={1}", EMAIL, PASSWORD);
        ASCIIEncoding encoding = new ASCIIEncoding();
        byte[] data = encoding.GetBytes(postString);
        CookieContainer cookies = new CookieContainer();
        request.CookieContainer = cookies;
        //request.AllowWriteStreamBuffering = true;
        request.Method = "POST";
        request.ContentType = "application/x-www-form-urlencoded";
        request.ContentLength = data.Length;
        request.Timeout = i_timeout;
        //request.UserAgent = "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.1) Gecko/2008070208 Firefox/3.0.1";
        //request.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";
        //request.Referer = "https://accounts.craigslist.org";

        using (Stream writer  = request.GetRequestStream())
        {
            writer.Write(data, 0, data.Length);
            //writer.Close();
        }

        StreamReader responseReader = new StreamReader(request.GetResponse().GetResponseStream());
        string responseData = responseReader.ReadToEnd();

        responseReader.Close();
        request.GetResponse().Close();
4

1 に答える 1

0

問題が見つかりました。リクエストを送信する URL はhttp://domain.comであり、http://www.domain.comに送信すると機能し、投稿を送信します。だから新しい質問はなぜですか?(私は自分自身に投票するという考えが好きではないので、答えは私の質問への答えを得るでしょう)

于 2013-10-29T14:26:17.580 に答える