似乎你在WebClient/WebRequest中发现了一个ug子,尽管微软可能有意地表明了这一点。 然而,当你在TW.通过时,URI的班子将这段话翻译成TW,没有时间。 由于WebClient/WebRequest parse strings into URI,你正在这个世界上消失。
你也许必须利用TcpClient来接手,并推出自己的网络客户。 任何改动:
TcpClient oClient = new TcpClient("www.shareprice.co.uk", 80);
NetworkStream ns = oClient.GetStream();
StreamWriter sw = new StreamWriter(ns);
sw.Write(
string.Format(
"GET /{0} HTTP/1.1
User-Agent: {1}
Host: www.shareprice.co.uk
",
"TW.",
"MyTCPClient" )
);
sw.Flush();
StringBuilder sb = new StringBuilder();
while (true)
{
int i = ns.ReadByte(); // Inefficient but more reliable
if (i == -1) break; // Other side has closed socket
sb.Append( (char) i ); // Accrue c to save page data
}
oClient.Close();
这将给你带来302个间接方向,从而把地点划出:与新地点一道执行上述任务。
HTTP/1.1 302 Found
Date: Wed, 11 Nov 2009 19:29:27 GMT
Server: lighttpd
X-Powered-By: PHP/5.2.4-2ubuntu5.7
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Location: /TW./TAYLOR-WIMPEY-PLC
Content-type: text/html; charset=UTF-8
Content-Length: 0
Set-Cookie: SSID=668d5d0023e9885e1ef3762ef5e44033; path=/
Vary: Accept-Encoding
Connection: close