• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            ++的博客

            你看不見我,你看不見我。。
            隨筆 - 22, 文章 - 0, 評論 - 2, 引用 - 0
            數據加載中……

            使用HttpWebRequest POST數據到服務器上

            HTTP協議中,向服務器傳遞參數的幾個位置是: HTTP Header / GET的字符串 / POST中間的Body
            下面的示例代碼演示如何簡單的POST數據到服務器.

            //?發送請求
            string?requestBody?=?string.Format("{0}={1}&{2}={3}&{4}={5}&{6}={7}&{8}={9}"
            ????,?HttpUtility.UrlEncode(
            "version_id",?Encoding.GetEncoding("GB2312"))
            ????,?HttpUtility.UrlEncode(m_VersionNo,?Encoding.GetEncoding(
            "GB2312"))
            ????,?HttpUtility.UrlEncode(
            "merchant_id",?Encoding.GetEncoding("GB2312"))
            ????,?HttpUtility.UrlEncode(m_MerchantID,?Encoding.GetEncoding(
            "GB2312"))
            ????,?HttpUtility.UrlEncode(
            "verifystring",?Encoding.GetEncoding("GB2312"))
            ????,?HttpUtility.UrlEncode(hashStr.ToString().ToLower(),?Encoding.GetEncoding(
            "GB2312"))
            ????,?HttpUtility.UrlEncode(
            "order_date",?Encoding.GetEncoding("GB2312"))
            ????,?HttpUtility.UrlEncode(m_OrderDate,?Encoding.GetEncoding(
            "GB2312"))
            ????,?HttpUtility.UrlEncode(
            "order_id",?Encoding.GetEncoding("GB2312"))
            ????,?HttpUtility.UrlEncode(m_OrderID,?Encoding.GetEncoding(
            "GB2312"))
            ????,?HttpUtility.UrlEncode(
            "retmode",?Encoding.GetEncoding("GB2312"))
            ????,?
            string.Empty
            ????);

            HttpWebRequest?request?
            =?(HttpWebRequest)HttpWebRequest.Create(m_GatewayURL);
            request.Method?
            =?"POST";
            request.KeepAlive?
            =?false;
            request.ContentType?
            =?"application/x-www-form-urlencoded";
            byte[]?aryBuf?=?Encoding.GetEncoding("GB2312").GetBytes(requestBody);
            request.ContentLength?
            =?aryBuf.Length;
            using(Stream?writer?=?request.GetRequestStream())
            {
            ????writer.Write(aryBuf,?
            0,?aryBuf.Length);
            ????writer.Close();
            ????writer.Dispose();
            }

            string?ret?=?string.Empty;
            using?(WebResponse?response?=?request.GetResponse())
            {
            ????StreamReader?reader?
            =?new?StreamReader(?response.GetResponseStream()
            ????????,?Encoding.GetEncoding(
            "GB2312")
            ????????);???
            ????ret?
            =?reader.ReadToEnd();
            ????reader.Close();
            ????reader.Dispose();
            }


            ContentType有3種方式可選,這里使用URLEncoded方式,比較簡單方便

            posted on 2008-06-19 10:21 Jerry.Wang 閱讀(2217) 評論(0)  編輯 收藏 引用 所屬分類: 開發

            99久久精品午夜一区二区| 色欲综合久久躁天天躁| 久久66热人妻偷产精品9| 久久国产精品国产自线拍免费| 国产精品久久99| 久久影院午夜理论片无码| 亚洲国产一成人久久精品| 国产99久久久久久免费看| 久久久久人妻一区二区三区| 久久国产精品99久久久久久老狼 | 欧美亚洲国产精品久久久久| 久久国产精品一国产精品金尊| 久久婷婷人人澡人人| 狠狠干狠狠久久| 色欲久久久天天天综合网 | 久久久久久久久久久久中文字幕 | 久久这里有精品视频| 亚洲精品无码久久千人斩| 久久91这里精品国产2020| 久久99国产精品尤物| 亚洲AV无码久久| 久久无码中文字幕东京热| 久久免费99精品国产自在现线| 久久91精品国产91久久户| 亚洲国产精品无码久久久蜜芽 | 91精品国产综合久久四虎久久无码一级| 日本WV一本一道久久香蕉| 国产精品99久久久精品无码| 久久se精品一区精品二区国产| 久久精品成人免费看| 天天综合久久久网| 情人伊人久久综合亚洲| 久久综合久久久| 久久av高潮av无码av喷吹| 久久99亚洲综合精品首页| 久久久久18| 亚洲欧美一级久久精品| 97精品依人久久久大香线蕉97 | 伊人久久大香线蕉综合5g| 中文字幕久久精品| 久久这里有精品|