asp.net解析请求报文

    NameValueCollection myHeader = new NameValueCollection();
            int i;
            string strKey;
            string result;
            myHeader = Request.Headers;

            int total = myHeader.Count;
            string strResult = "";
            //获取header里的signature参数的值
            for (i = 0; i < total; i++)
            {
                strKey = myHeader.GetKey(i);
                if (strKey == "signature")
                {
                    strResult = myHeader.Get(strKey);

                }
                //strResult += "<p>名字:" + strKey + "值:" + myHeader.Get(strKey)/* + myHeader.Get(i)*/ + "</p>";
            }
            //获取请求的body的值
            Stream resStream = HttpContext.Current.Request.InputStream;
            StreamReader sr = new StreamReader(resStream, System.Text.Encoding.Default);
            string requestXml = sr.ReadToEnd();

            result = strResult;

  

posted @ 2016-08-25 14:03  ~沐风  阅读(1060)  评论(0编辑  收藏  举报