讀取Request.InputStream的數(shù)據(jù)后娃惯,InputStream的指針指向了最后趾浅,后端不能正確獲得參數(shù)信息馒稍。
應(yīng)重新置位InputStream的指針位置:request.InputStream.Position=0;
主體代碼如下:
var inputStream = HttpContext.Current.Request.InputStream;
? ? ? ? ? ? if(null!=inputStream && inputStream.Length > 0)
? ? ? ? ? ? {? ? ? ? ? ? ?
? ? ? ? ? ? ? ? byte[] byts = new byte[inputStream.Length];
? ? ? ? ? ? ? ? inputStream.Read(byts, 0, byts.Length);
? ? ? ? ? ? ? ? //重新置位指針的位置
? ? ? ? ? ? ? ? request.InputStream.Position=0;
? ? ? ? ? ? ? ? string reqData = System.Text.Encoding.Default.GetString(byts);
? ? ? ? ? ? ? ?//業(yè)務(wù)邏輯
? ? ? ? ? ? }