• C# 后台POST请求(winform)


         //data:参数  URL:路径

      public static string PostWebRequest(string Data, string URL)
            {
                CookieContainer cc = new CookieContainer();
                string postData = Data;
                byte[] byteArray = Encoding.UTF8.GetBytes(postData); // 转化
                HttpWebRequest webRequest2 = (HttpWebRequest)WebRequest.Create(new Uri(URL));
                webRequest2.CookieContainer = cc;
                webRequest2.Method = "POST";
                webRequest2.ContentType = "application/x-www-form-urlencoded";
                webRequest2.ContentLength = byteArray.Length;
                Stream newStream = webRequest2.GetRequestStream();
                newStream.Write(byteArray, 0, byteArray.Length);    //写入参数
                newStream.Close();
                HttpWebResponse response2 = (HttpWebResponse)webRequest2.GetResponse();
                StreamReader sr2 = new StreamReader(response2.GetResponseStream(), Encoding.UTF8);
                string text2 = sr2.ReadToEnd();
                if (text2 != null && text2.Length > 0)
                {
                    return text2;
                }
                return "";
            }

  • 相关阅读:
    import和require的区别
    React Native--Animated:`useNativeDriver`is not supported because the native animated module is missing
    XMLHttpRequest
    react-native中更改android/ios的入口文件
    react-native 跳转到ios/android 权限设置界面
    CocoaPods安装和使用
    React、React Native面试题
    UIBarButtonSystemItem 样式
    (转)自定义UITabBar
    ios 代码规范
  • 原文地址:https://www.cnblogs.com/ellanjianx/p/3782034.html
Copyright © 2020-2023  润新知