返回错误:(405)方法不允许

时间:2017-07-04 08:46:35

标签: c#

目前我正在尝试制作网络抓取工具,但我遇到了这个错误:

  

抛出异常:System.dll中的“System.Net.WebException”

     

其他信息:远程服务器返回错误:(405)Method Not Allowed。

这是我的代码:

Stream receiveStream = null;
url = item1;
HttpWebRequest request1 = (HttpWebRequest)WebRequest.Create(url);
HttpWebResponse response1 = (HttpWebResponse)request1.GetResponse();
receiveStream = response1.GetResponseStream();
StreamReader readStream = null;
if (response.CharacterSet == null)
{
    readStream = new StreamReader(receiveStream);
}
else
{
    readStream = new StreamReader(receiveStream, Encoding.GetEncoding(response.CharacterSet));
}

html = readStream.ReadToEnd();

response1.Close();
readStream.Close();

如果收到此错误,如何跳至下一个“item1”?

0 个答案:

没有答案