码迷,mamicode.com
首页 > Web开发 > 详细

HTTP请求

时间:2017-12-23 17:20:24      阅读:208      评论:0      收藏:0      [点我收藏+]

标签:gpo   ken   img   request   count   htm   src   技术   style   

技术分享图片
        string url = https://xxx.xxxx.com/Services/Login.ashx;
        string json = "";
        Encoding encoding = Encoding.UTF8;
        HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
        request.Method = "post";
        request.Headers.Add("Method", context.Request.Headers["Method"]);
        request.Headers.Add("timespan", context.Request.Headers["Timespan"]);
        request.Headers.Add("Nonce", context.Request.Headers["Nonce"]);
        request.Headers.Add("Token", context.Request.Headers["Token"]);
        request.Headers.Add("Account", System.Web.HttpUtility.UrlDecode(context.Request.Headers["Account"]));
        request.Headers.Add("Source", context.Request.Headers["Source"]);
        request.Headers.Add("Version", context.Request.Headers["Version"]);
        request.Headers.Add("Sign", context.Request.Headers["Sign"]);


        request.Accept = "text/html, application/xhtml+xml, */*";
        request.ContentType = "application/x-www-form-urlencoded";
        byte[] buffer = encoding.GetBytes(RequestString.ToString());
        request.ContentLength = buffer.Length;
        request.GetRequestStream().Write(buffer, 0, buffer.Length);
        HttpWebResponse response = (HttpWebResponse)request.GetResponse();
        using (StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8))
        {
            json = reader.ReadToEnd();
        }
View Code

 

HTTP请求

标签:gpo   ken   img   request   count   htm   src   技术   style   

原文地址:http://www.cnblogs.com/liandy0906/p/8093611.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!