--post  请求

public static string PostMsg(Guid orgid, int page, int rows)
        {
            System.Net.WebClient client = new System.Net.WebClient();

string postData = "{\"groupid\": \"c3c5e53cd423480aa907f123338e0850\",\"type\": [\"1\",\"3\",\"4\"],\"start\":\"" + page + "\",\"end\":\"" + rows + "\"}";
            byte[] sendData = Encoding.GetEncoding("GB2312").GetBytes(postData);

client.Headers.Add("Content-Type", "application/json;charset=UTF-8");
            client.Headers.Add("ContentLength", sendData.Length.ToString());

var recData = client.UploadData("http://122.226.255.148:8098/aam/rest/member/query", "POST", sendData);

var result = Encoding.GetEncoding("UTF-8").GetString(recData);
            return result;
        }

--get  请求

/// <summary>
        /// 发送http请求
        /// </summary>
        /// <param name="url"></param>
        /// <param name="msg"></param>
        /// <returns></returns>
        public static string PostMsg(string url)
        {
            System.Net.WebClient client = new System.Net.WebClient();
            System.IO.Stream strm = client.OpenRead(url);
            System.IO.StreamReader reader = new System.IO.StreamReader(strm);
            string resultData = reader.ReadToEnd();
            return resultData;
        }

WebClient 使用的更多相关文章

  1. 跨域请求——WebClient通过get和post请求api

    AJAX不可以实现跨域请求,经过特殊处理才行.一般后台可以通过WebClient实现跨域请求~ //get 请求        string url = string.Format("htt ...

  2. C#通过WebClient/HttpWebRequest实现http的post/get方法

    C#通过WebClient/HttpWebRequest实现http的post/get方法 http://www.cnblogs.com/shadowtale/p/3372735.html

  3. WebClient 实现多文件/文本同时上传

    public class CreateBytes { Encoding encoding = Encoding.UTF8; /**/ /// <summary> /// 拼接所有的二进制数 ...

  4. WebClient 数据传输

    数据提交 post  ,get public string WebClientPost(string PostData, string PostUrl, string Type) { string p ...

  5. C# 文件下载 : WebClient

    最近更新了一个下载小工具,主要提升了下面几点: 1. 在一些分公司的局域网中,连接不上外网 2. 服务器上的文件更新后,下载到的还是更新前的文件 3. 没有下载进度提示 4. 不能终止下载 下面和大家 ...

  6. C# 发送Http请求 - WebClient类

    WebClient位于System.Net命名空间下,通过这个类可以方便的创建Http请求并获取返回内容. 一.用法1 - DownloadData string uri = "http:/ ...

  7. c# WebClient Get Post 方法

    public string GetData(string url) { string data; using (var client = new WebClient()) { using (var s ...

  8. c# WebClient文件下载

    public void HttpDownload(string url, string path, ResourceType type) { using (var client = new WebCl ...

  9. [解决WebClient或HttpWebRequest首次连接缓慢问题]

    [编程环境]Visual Studio 2010, NET4.0 [开发语言]C#, 理论上VB.NET等依赖.NET Framework框架的语言均受此影响 [问题描述] 使用HttpWebRequ ...

  10. winform客户端利用webClient实现与Web服务端的数据传输

    由于项目需要,最近研究了下WebClient的数据传输.关于WebClient介绍网上有很多详细介绍,大概就是利用WebClient可以实现对Internet资源的访问.无外乎客户端发送请求,服务端处 ...

随机推荐

  1. class 函数

    cocos2d-x 3.3 lua 版本的class函数用法: local FightScene = class("FightScene", function() return c ...

  2. 无法安装 DotNetCore.1.0.0-VS2015Tools.Preview2解决方法

    安装 DotNetCore.1.0.0-VS2015Tools.Preview2,已经安装vs2015update3,还是提示检测到 Visual Studio 2015 Update 3没有完全安装 ...

  3. 常用正则表达式大全!(例如:匹配中文、匹配html)

    一.常见正则表达式 匹配中文字符的正则表达式: [u4e00-u9fa5]    评注:匹配中文还真是个头疼的事,有了这个表达式就好办了  匹配双字节字符(包括汉字在内):[^x00-xff]  评注 ...

  4. AngularJS中的身份验证

    欢迎大家指导与讨论 : )  一.  身份验证的意义  首先呢,网络应用的身份验证的意图在于:保护网站中的重要资源.基于某些原因这些资源并不能公开,比如付费资源(交过钱的用户才能上的网络课程),或者一 ...

  5. spring mvc4:异常处理

    前面学习过struts2的异常处理,今天来看下spring mvc4的异常处理: 一.Servlet配置文件修改 <bean id="exceptionResolver" c ...

  6. 详解javascript 存储

    javascript用于存储的方式可谓是多种多样,善于应用‘存储’可以大大的提高网站的性能,博主结合日常开发常见需求做一下总结,希望对大家有用- 1.cookie 存储大小:   4kb左右,以20个 ...

  7. 【语言基础】c++ 基本数据类型与字节数组(string,char [] )之间的转化方法

    有时候我们需要将基本数据类型转化为字节,以便写入文件,然后必要时还需要将这些字节读出来.有人说,为啥不把数字直接存进文件呢?比如:100,000,000,我们直接存数字明文到文件那就是9个字符(cha ...

  8. 实用工具 : Xaml Power Toys

    最近挺忙, 憋了一肚子的东西没有分享. 今天分享一个 Xamarin.Forms / WPF 的增强工具 , Visual Studio 扩展 : Xaml Power Toy 可以直接在 VS201 ...

  9. 利用manifest文件对程序目录下的dll进行分类

    1 背景 对于大部分的券商和机构投资者,只能通过有交易所交易系统接入资质的券商提供的柜台系统来进行现货交易.相对于期货市场,现货市场的柜台系统千差万别,接入协议有明文字符串.二进制数据和FIX协议等, ...

  10. 系统升级日记(3)- 升级SharePoint解决方案和Infopath

    最近一段时间在公司忙于将各类系统进行升级,其最主要的目标有两个,一个是将TFS2010升级到TFS2013,另外一个是将SharePoint 2010升级到SharePoint 2013.本记录旨在记 ...