///<summary>
///采用https协议访问网络
///</summary>
///<param name="URL">url地址</param>
///<param name="strPostdata">发送的数据</param>
///<returns></returns>
public string OpenReadWithHttps(string URL, string strPostdata)
{
    Encoding encoding = Encoding.Default;
    HttpWebRequest request = (HttpWebRequest)WebRequest.Create(URL);
    request.Method = "post";
    request.Accept = "text/html, application/xhtml+xml, */*";
    request.ContentType = "application/x-www-form-urlencoded";
    CookieContainer objcok = new CookieContainer();
    objcok.Add(new Uri("http://sufei.cnblogs.com"), new Cookie("键", "值"));
    objcok.Add(new Uri("http://sufei.cnblogs.com"), new Cookie("键", "值"));
    objcok.Add(new Uri("http://sufei.cnblogs.com"), new Cookie("sidi_sessionid", "360A748941D055BEE8C960168C3D4233"));
    request.CookieContainer = objcok;
 
    byte[] buffer = encoding.GetBytes(strPostdata);
    request.ContentLength = buffer.Length;
 
    request.GetRequestStream().Write(buffer, 0, buffer.Length);
    HttpWebResponse response = (HttpWebResponse)request.GetResponse();
    StreamReader reader = new StreamReader(response.GetResponseStream(), System.Text.Encoding.GetEncoding("utf-8"));
    return reader.ReadToEnd();
}

OpenReadWithHttps的更多相关文章

  1. c# HttpWebRequest 与 HttpWebResponse

    如果你想做一些,抓取,或者是自动获取的功能,那么就跟我一起来学习一下Http请求吧.本文章会对Http请求时的Get和Post方式进行详细的说明,在请求时的参数怎么发送,怎么带Cookie,怎么设置证 ...

  2. C# HttpWebRequest 绝技 根据URL地址获取网页信息

    如果要使用中间的方法的话,可以访问我的帮助类完全免费开源:C# HttpHelper,帮助类,真正的Httprequest请求时无视编码,无视证书,无视Cookie,网页抓取 1.第一招,根据URL地 ...

  3. C#、.NET网络请求总结(WebClient和WebRequest)

    1.关于WebClient第三方的封装,支持多文件上传等 using System; using System.Collections.Generic; using System.Text; usin ...

  4. C# HttpWebRequest 绝技 转至 http://www.sufeinet.com/

    转至: 在线测试工具http://www.sufeinet.com/thread-3690-1-1.htmlc# HttpWebRequest与HttpWebResponse 绝技    如果你想做一 ...

  5. C#_抓包HttpWebRequest跟HttpWebResponse

    1.第一招,根据URL地址获取网页信息  这招是入门第一式, 特点: 1.最简单最直观的一种,入门课程. 2.适应于明文,无需登录,无需任何验证就可以进入的页面. 3.获取的数据类型为HTML文档. ...

  6. c# HttpWebRequest与HttpWebResponse(转)

    如果你想做一些,抓取,或者是自动获取的功能,那么就跟我一起来学习一下Http请求吧.本文章会对Http请求时的Get和Post方式进行详细的说明,在请求时的参数怎么发送,怎么带Cookie,怎么设置证 ...

  7. HttpWebRequest和HttpWebResponse

    原文:http://blog.csdn.net/haitaofeiyang/article/details/18362225 申公前几日和一个客户做系统对接,以前和客户对接一般采用webservice ...

  8. c# HttpWebRequest与HttpWebResponse 绝技(转载)

    c# HttpWebRequest与HttpWebResponse 绝技    如果你想做一些,抓取,或者是自动获取的功能,那么就跟我一起来学习一下Http请求吧.本文章会对Http请求时的Get和P ...

  9. 接口post +json +bean

    public ReturnBean<DealBean> getMember(String tagtype, String tag) { try { String requestUrl = ...

随机推荐

  1. 学习RMQ-ST表

    RMQ一般是一个二维数组,用$dp[i][j]$表示起点为i开始连续数$2^j$个元素其中的最值,由于对于一个闭区间有:$R-L+1=len$因此也可以用另外一种记法:闭区间为$[i,i+2^j-1] ...

  2. bzoj3609【HEOI2014】人人尽说江南好

    题意:http://www.lydsy.com/JudgeOnline/problem.php?id=3609 sol :博弈论  通过打表找规律,发现答案是%m循环的,且当m为偶数时取反  因为我太 ...

  3. CodeForces 605 E. Intergalaxy Trips

    E. Intergalaxy Trips time limit per test:2 seconds memory limit per test:256 megabytes input:standar ...

  4. POJ1595 Prime Cuts

    Prime Cuts Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 11961   Accepted: 4553 Descr ...

  5. HTTP 错误 401.2 - Unauthorized

    最近开始拾起Asp.net方面的知识,遇到如下这个问题 HTTP 错误 401.2 - Unauthorized 由于身份验证头无效,您无权查看此页. 解决方法: >IIS管理 >功能视图 ...

  6. 【Visual Studio】解决错误 fatal error C1010: unexpected end of file while looking for precompiled head(转)

    原文转自 http://blog.csdn.net/liuqiyao_01/article/details/38867145 在编译VS时候,出现fatal error C1010: unexpect ...

  7. 编译程序加不加 -lpthread 的区别【转】

    转自:http://www.cnblogs.com/Swartz/articles/3939382.html 作者:Lokki 出处:http://www.cnblogs.com/Swartz/ 欢迎 ...

  8. 《Linux命令行与shell脚本编程大全 第3版》Linux命令行---7

    以下为阅读<Linux命令行与shell脚本编程大全 第3版>的读书笔记,为了方便记录,特地与书的内容保持同步,特意做成一节一次随笔,特记录如下:

  9. HDU5032 Always Cook Mushroom(树状数组&&离线)

    树状数组+询问离线.一个优化是需要的,就是先对1000*1000个点先排序,而不是每次都生成这1000*1000个点然后和询问一起排序,那样会tle. #include <iostream> ...

  10. 修正MYSQL错误数据的一个存储过程

    -- 添加索引 CREATE INDEX idx_STRUCTURE_ID ON t_resource_info(STRUCTURE_ID); DROP PROCEDURE IF EXISTS `P_ ...