zoukankan      html  css  js  c++  java
  • WinForm 程序Post GEt web程序方法

      前段时间 做.net 程序要读取java的借口,但是选择了 java返回一个json串 然后.net程序加载时去读取 java的返回信息然后解析用来读取数据

      public static void PostDataByRifd()
            {
                try
                {
                    System.Net.HttpWebRequest req = (System.Net.HttpWebRequest)System.Net.WebRequest.Create("www.baidu.com");

                    byte[] requestBytes = Encoding.ASCII.GetBytes("");
                    req.Method = "post";
                    req.ContentType = "application/x-www-form-urlencoded";
                    req.ContentLength = requestBytes.Length;

                    Stream requestStream = req.GetRequestStream();
                    requestStream.Write(requestBytes, 0, requestBytes.Length);
                    requestStream.Close();
                    System.Net.HttpWebResponse res = (System.Net.HttpWebResponse)req.GetResponse();
                    StreamReader sr = new StreamReader(res.GetResponseStream(), Encoding.Default);
                    string backstr = sr.ReadToEnd();            
                    sr.Close();
                    res.Close();


                

                 

                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }

  • 相关阅读:
    P4932 浏览器 题解
    P1627 [CQOI2009]中位数 题解
    P4626 一道水题 II 题解
    P1439 【模板】最长公共子序列 题解
    P2324 [SCOI2005]骑士精神 题解
    P1784 数独 题解
    浅谈 Dancing Links X 算法
    P5905 【模板】Johnson 全源最短路 题解
    线性预处理阶乘,逆元和组合数
    需要支持多种操作的线段树该如何确定运算顺序?
  • 原文地址:https://www.cnblogs.com/Traner/p/2819964.html
Copyright © 2011-2022 走看看