就是Get签到这里出现了异常,其他的不会。网上说是将IIS的"Web服务扩展"中的"WebDAV"设置成"允许"。
但是是Win7的不知道在哪设置
private string GetHtmlByGet(string url,CookieContainer cookie)
{
try
{
HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(url);
request.Method = "Get";
request.UserAgent = "User-Agent: Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)";
request.CookieContainer = new CookieContainer();
request.CookieContainer = cookie;
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
return null;
}
调用如下:
string url = "http://igame.qq.com";
var cookie = String2Cookies(url, " ptui_loginuin=499324311; pt2gguin=o0499324311; RK=rPmGQhvUsB; ptcz=9ebe5fac77ccb5149a48367d3ae2467577c80dd1b7d674c6c23c5ea6f09bc9b9; pgv_pvi=5753970688; pgv_pvid=920033533; ptisp=cm; pgv_si=s8882947072; pgv_info=pgvReferrer=&ssid=s8803128624; ied_rf=igame.qq.com/undefined; p_uin=o0499324311; p_skey=B3WUp8B5QGPqYdG7hSgo*ZWhHDqO3nNaF7Tlm94G9YQ_; pt4_token=Ts1Asurwe8kcp*1Oc9dkEw__; 499324311_logtime=1410140508; 499324311_centergid=2");
string html = GetHtmlByGet("http://igame.qq.com/interface/fn/index.php?logicname=c_igamesign_setHonorNotice&gid=2&g_tk=519248902&json=1", cookie);
------解决思路----------------------
这个你要先明白501的错误是什么,然后再根据错误提示去解决