public static string PostWebRequest2()
{
HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create("http://183.66.231.18:8184/api/services/app/ChildSystem/checkLogin");//这是你要提交的url
Encoding encoding = Encoding.UTF8; IDictionary<string, string> para = new Dictionary<string, string>();
para.Add("ticket", "22d0a6a46bbdf44ec718f600b012b261"); StringBuilder buffer = new StringBuilder();//这是要提交的数据
int i = ; foreach (string key in para.Keys)
{
if (i > )
{
buffer.AppendFormat("&{0}={1}", key, para[key]);
}
else
{
buffer.AppendFormat("{0}={1}", key, para[key]);
}
i++;
} byte[] bs = Encoding.UTF8.GetBytes(buffer.ToString());//UTF-8
string responseData = String.Empty;
req.Method = "POST";
req.ContentType = "application/x-www-form-urlencoded;charset=utf-8";
req.ContentLength = bs.Length;
using (Stream reqStream = req.GetRequestStream())
{
reqStream.Write(bs, , bs.Length);
reqStream.Close();
}
using (HttpWebResponse response = (HttpWebResponse)req.GetResponse())
{
using (StreamReader reader = new StreamReader(response.GetResponseStream(), encoding))
{
responseData = reader.ReadToEnd().ToString();
return responseData;
}
}
}

对应的 Postman 界面

C# 请求数据 方式1的更多相关文章

  1. vue的请求数据方式

    一,vue-resource请求数据 介绍:vue-resource请求数据方式是官方提供的一个插件 步骤: 1,npm安装     npm  install vue-resource  --save ...

  2. C# 中请求数据方式

    #region 根据URL获取结果集        /// <summary>        /// 根据URL获取结果集 默认为GET,如果数据量大了可以传入POST        // ...

  3. 爬取'Content-Type': 'text/plain;charset=UTF-8' ,发送请求数据方式

    解决方式 直接以字符串的方式发送data就可以得到响应数据 import requests data = 'k1:v1,k2:v2' requests.post(url, data=data)

  4. Vue vue-resource三种请求数据方式pet,post,jsonp

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  5. Python实现接口测试中的常见四种Post请求数据

    前情: 在日常的接口测试工作中,模拟接口请求通常有两种方法, 利用工具来模拟,比如fiddler,postman,poster,soapUI等 利用代码来模拟,使用到一些网络模块,比如HttpClie ...

  6. get和post方式请求数据,jsonp

    get方式请求数据: p.p1 { margin: 0.0px 0.0px 0.0px 0.0px; font: 19.0px Consolas; color: #289c97 } p.p2 { ma ...

  7. 前端向服务器请求数据并渲染的方式(ajax/jQuery/axios/vue)

    原理: jQuery的ajax请求:complete函数一般无论服务器有无数据返回都会显示(成功或者失败都显示数据): return result

  8. HttpClient get和HttpClient Post请求的方式获取服务器的返回数据

    1.转自:https://blog.csdn.net/alinshen/article/details/78221567?utm_source=blogxgwz4 /*  * 演示通过HttpClie ...

  9. post方式请求数据

    post方式请求数据 分析: 1.将请求方式改成post conn.setRequestMethod("POST"); 2.设置连接可以输出 conn.setDoOutput(tr ...

随机推荐

  1. 【题解】Largest Rectangle in a Histogram [SP1805] [POJ2559]

    [题解]Largest Rectangle in a Histogram [SP1805] [POJ2559] [题目描述] 传送: \(Largest\) \(Rectangle\) \(in\) ...

  2. 使用DbVisualizer 10.0.20 查询ES中的索引时需要注意的事项

    查询前5条数据 光标停在某一个查询结果框中,左下角会显示该字段的类型 查询类型是text的字段使用单引号,使用双引号查询会报错

  3. c#---Socean.RPC框架实测[并发量13w][响应时间0.04ms]

    目录1.高性能RPC框架:Socean.RPC 前言 经过一段时间的优化,Socean.RPC的性能又提高了一些,不过这差不多是socketAPM模型的极限了.本框架仅仅2000多行代码,无第三方框架 ...

  4. WCF学习笔记(一)---我的第一个WCF程序

    一.创建WCF程序   1.创建一个控制台程序(WCFBlog)   2.添加wcf项目   3.将默认的IService1和Service1改成自己的名字   4.在ICalculateServic ...

  5. linux环境:FTP服务器搭建

    转载及参考至:https://www.linuxprobe.com/chapter-11.html https://www.cnblogs.com/lxwphp/p/8916664.html 感谢原作 ...

  6. Java自学-类和对象 枚举类型

    枚举类型 步骤 1 : 预先定义的常量 枚举enum是一种特殊的类(还是类),使用枚举可以很方便的定义常量 比如设计一个枚举类型 季节,里面有4种常量 public enum Season { SPR ...

  7. 28、IE报vuex requires a Promise polyfill in this browser问题解决

    解决方法第一步: 安装 babel-polyfill . babel-polyfill可以模拟ES6使用的环境,可以使用ES6的所有新方法 npm install --save babel-polyf ...

  8. 《JavaScript高级程序设计》笔记:高级技巧

    高级函数 安全的类型检测 在任何值上调用Object原生的toString()方法,都会返回一个[object NativeConstructorName]格式的字符串.每个类在内部都有一个[[Cla ...

  9. open abc.txt: The system cannot find the file specified

    使用io/ioutil包读取文件时报错:open abc.txt: The system cannot find the file specified 原因是:ioutil.ReadFile()这个方 ...

  10. box-cox解读

    可以额外参考资料:https://blog.csdn.net/sinat_26917383/article/details/77864582,http://www.dataguru.cn/articl ...