在线运行.NET代码
https://dotnetfiddle.net/
https://try.dot.net/
C# 发送Http协议 模拟 Post Get请求
1.参数 paramsValue的格式 要和 Reques.ContentType一致,
如果 contentype "application/x-www-form-urlencoded" 表单类型,那么 参数为 a=1&b=2 形式
如果 。。。 "application/json" json 类型 那么参数就为 "{a:1,b:2}" 格式
2.可以添加自定义header, add(key,value)
接受获取header Request.Headers.Get(key)

public static string HttpGet(string url)
{
string result=string.Empty;
try
{
HttpWebRequest wbRequest = (HttpWebRequest)WebRequest.Create(url);
wbRequest.Method = "GET";
HttpWebResponse wbResponse = (HttpWebResponse)wbRequest.GetResponse();
using (Stream responseStream = wbResponse.GetResponseStream())
{
using (StreamReader sReader = new StreamReader(responseStream))
{
result = sReader.ReadToEnd();
}
}
}
catch (Exception ex)
{ }
return result;
}

HttpGet

public static string HttpPost(string url, string paramData, Dictionary<string, string> headerDic = null)
{
string result = string.Empty;
try
{
HttpWebRequest wbRequest = (HttpWebRequest)WebRequest.Create(url);
wbRequest.Method = "POST";
wbRequest.ContentType = "application/x-www-form-urlencoded";
wbRequest.ContentLength = Encoding.UTF8.GetByteCount(paramData);
if (headerDic != null && headerDic.Count > )
{
foreach (var item in headerDic)
{
wbRequest.Headers.Add(item.Key, item.Value);
}
}
using (Stream requestStream = wbRequest.GetRequestStream())
{
using (StreamWriter swrite = new StreamWriter(requestStream))
{
swrite.Write(paramData);
}
}
HttpWebResponse wbResponse = (HttpWebResponse)wbRequest.GetResponse();
using (Stream responseStream = wbResponse.GetResponseStream())
{
using (StreamReader sread = new StreamReader(responseStream))
{
result = sread.ReadToEnd();
}
}
}
catch (Exception ex)
{ } return result;
}

HttpPost
在线运行.NET代码的更多相关文章
- 在线运行HTML代码器
在线运行HTML代码器(二)和前面的(一)大同小异,关键部分为JS代码,这次是把运行器所有的JS功能集中放在一起.以下为HTML代码: <!DOCTYPE html PUBLIC "- ...
- 发现一个可以在线运行JS代码的网站
平时可以在这里玩 http://jsbin.com/
- 在线运行python代码-python代码运行助手
https://www.liaoxuefeng.com/wiki/0014316089557264a6b348958f449949df42a6d3a2e542c000/001432523496782e ...
- 在线运行Javascript,Jquery,HTML,CSS代码
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" http://www.w3.org/TR/xht ...
- 网页HTML代码在线运行器
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- 通过jstack定位在线运行java系统故障_案例1
问题描述: 在一个在线运行的java web系统中,会定时运行一个FTP上传的任务,结果有一天发现,文件正常生成后却没有上传. 问题初步分析: 1.查看日志文件 发现这个任务只打印了开始进入FTP处理 ...
- 实现Vue 的 markdown 文档可以在线运行(vue-markdown-run)
闲暇时间我用Vue框架写了一个博客,编辑器是用的markdown文本的形式,介绍性+描述完全能满足我的需求,但是,如果想在线运行我markdown文本中的Vue组件代码,则无法实现了, 于是我就自己写 ...
- 浏览器地址栏运行JavaScript代码
这个很多人应该还是知道的,在浏览器地址栏可以直接运行JavaScript代码,做法是以javascript:开头后跟要执行的语句.比如: javascript:alert('hello from ad ...
- C#在线运行--cmd方法
此次C#在线运行采用cmd.exe用csc对文件进行编译,然后再运行的思路实现在线运行的效果.不过会生成二个文件(.cs和.exe),可能需要定期清除临时文件夹. 首先利用时间戳生成唯一文件名, ...
随机推荐
- 【AGC 036C】GP2
https://atcoder.jp/contests/agc036/tasks/agc036_c 题意 有一个长度为 $n$ 的非负整数序列 $x$,初始时全为 $0$.一次操作定义为选择一对正整数 ...
- dpkg -i libequinox-osgi-java_3.8.1-8_all.deb
dpkg -i libequinox-osgi-java_3.8.1-8_all.deb dpkg -i libequinox-osgi-java_3.8.1-8_all.deb https://ww ...
- 第二章 Vue快速入门-- 17 v-for指令的四种使用方式
1.v-for循环普通数组 <!DOCTYPE html> <html lang="en"> <head> <meta charset=& ...
- oracle 环境变量问题
ORACLE_HOME 配置为oracle ..\dbhome_1 配置错误可能导致监听起不来 (也有可能是在装client时可能会更改了之前变量的值) TNS_ADMIN ...
- Java技术综述
自己打算好好学习下Java,所以想先明晰Java开发中到底有哪些技术,以便以后学习的过程中,可以循序渐进,随着学习的深入,本文将不断更新. Java基础教程将Java的入门基础知识贯穿在一个实例中,逐 ...
- 手机端css实现active伪类
今天遇到手机端的css中a标签的active不起作用,原本想循环a标签,给当前的a标签添加class来解决,可觉得有点儿小麻烦,经查资料了解到解决此问题,只需要添加一个touchstart的空事件即可 ...
- 【leetcode】1260. Shift 2D Grid
题目如下: Given a 2D grid of size n * m and an integer k. You need to shift the grid k times. In one shi ...
- Codeforces Round #325 (Div. 2) A. Alena's Schedule 暴力枚举 字符串
A. Alena's Schedule time limit per test 1 second memory limit per test 256 megabytes input standard ...
- Codeforces 1213E Two Small Strings
cf题面 中文题意 给个n,再给两个长度为2的字符串,要求构造一个长度为\(3n\)的字符串,a.b.c三个字母各n个,且构造出的字符串子串中不能出现给定的两个字符串.如果不存在这样的字符串,就输出N ...
- fiddler(一)、下载及安装
fiddler 官网地址:https://www.telerik.com/fiddler 进入页面后点击 Free download 进入下载页面,填写用途,邮箱和国家等信息后,点击Download ...