如标题所诉,和普通http访问没多大差别,只需要加一句
ServicePointManager.SecurityProtocol = (SecurityProtocolType)3072;
下面是完整的一个列子
public static string DoRequest(string Url, string cookieStr)
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(Url);
request.Timeout = 1000 *900;
request.Headers.Add(HttpRequestHeader.Cookie, cookieStr);
request.UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.63 Safari/537.36";
ServicePointManager.SecurityProtocol = (SecurityProtocolType)3072;// SecurityProtocolType.Tls1.2;
string back ="";
try {
WebResponse response = request.GetResponse();
StreamReader reader = new StreamReader(response.GetResponseStream(), System.Text.Encoding.UTF8);
back = reader.ReadToEnd();
reader.Close();
reader.Dispose();
response.Close();
}
catch(Exception ex){
back = ex.Message;
}
return back;
}