asp.net mvc5取得post和get的数据和模拟发送
2015-01-26 12:18
369 查看
可以放在控制器的入口函数中,这样载入就会被调用
asp.net mvc,get+post:
View Code
asp.net mvc,get+post:
using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Net; using System.Text; using System.Threading.Tasks; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { var targetWeb = "http://localhost:60797?Test1=123&Test2=345"; HttpWebRequest req = (HttpWebRequest)WebRequest.Create(targetWeb); req.ContentType = "application/x-www-form-urlencoded"; req.Method = "GET"; WebResponse resp = req.GetResponse(); var stream = resp.GetResponseStream(); StreamReader reader = new StreamReader(stream); string response = reader.ReadToEnd(); req.Abort(); resp.Close(); Console.WriteLine("目标地址: " + targetWeb); Console.WriteLine("返回响应: " + response); Console.Read(); } } }
View Code
相关文章推荐
- C#模拟Post和Get方式发送数据
- C#模拟Post和Get方式发送数据
- C#模拟Post和Get方式发送数据的技巧
- 向Web站点发送GET请求,POST请求,并从Web站点取得相应数据示例
- C#模拟Post和Get方式发送数据的技巧
- 调试json提交数据,模拟json发送数据POST或GET
- file_get_contents 模拟POST数据发送
- httpClient使用,1 发送post请求 2 发送get请求取得接口中的数据
- C#模拟Post和Get方式发送数据
- 模拟表单发送POST,GET请求获取数据
- C#模拟Post和Get方式发送数据的技巧
- C#模拟Post和Get方式发送数据 保持COOKIE
- C#模拟Post和Get方式发送数据
- post和get方式发送数据
- WebClient模拟Post发送接收数据
- php中用socket模拟http中post或者get提交数据
- 模拟发送POST或Get请求
- socket模拟http中post或者get提交数据,并获得响应数据
- 模拟http 提示数据 POST 和 GET
- 使用jQuery的ajax的post与get发送数据到指定url