找到你要的答案

Q:Quickest way to get StatusCode while posting data

Q:在发布数据最快的方式得到的状态码

What i'm wanting to do it post data (ID=123456&start=true) and have it return the website status (200, 404, 401, etc.) I don't want any other content except for the StatusCode, what is my best way of doing this?

I have been using

HttpWebRequest request =
    (HttpWebRequest)WebRequest.Create("http://example.com/test.php");
request.Method = "POST";

But it seems to download the whole page before it gives me the StatusCode.

I have also tried:

request.Method = "HEAD";

But that wont let me send any post data with it.

What i'm wanting to do it post data (ID=123456&start=true) and have it return the website status (200, 404, 401, etc.) I don't want any other content except for the StatusCode, what is my best way of doing this?

我一直在用

HttpWebRequest request =
    (HttpWebRequest)WebRequest.Create("http://example.com/test.php");
request.Method = "POST";

但似乎下载整个页面之前,它给我的状态码。

我也试过:

request.Method = "HEAD";

但这不会让我发送任何POST数据与它。

c#