asp.net解析请求报文

时间:2024-09-30 10:37:20
    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;