我正在尝试使用 HTTP 302 找出 URI 重定向到的 URL
例如,我有一个网页:http://www.example.com/pagenothere.php重定向到http://www.google.com
我使用了一种方法来尝试检索详细信息,但我无法通过它找到响应代码或重定向 url:
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(urlString);
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
request.Accept = "text/plain";
MessageBox.Show("Response headers");
MessageBox.Show(" Protocol version: " + response.ProtocolVersion);
MessageBox.Show(" Status code: " + response.StatusCode);
MessageBox.Show(" Status description: " + response.StatusDescription);
MessageBox.Show(" Content encoding: " + response.ContentEncoding);
MessageBox.Show(" Content length: " + response.ContentLength);
MessageBox.Show(" Content type: " + response.ContentType);
MessageBox.Show(" Last Modified: " + response.LastModified);
MessageBox.Show(" Server: {0}", response.Server);
MessageBox.Show(" Length using method: {0}\n", response.GetResponseHeader("Content-Length"));