在实际应用doc.Load(Request.InputStream)的时候,doc.Load方法内置默认释放流
造成再次度Request.InputStream的时候,代码报错
替换方法:
XmlDocument doc = new XmlDocument();
Stream stream = Request.InputStream;
byte[] bytes = new byte[stream.Length];
stream.Read(bytes, 0, bytes.Length);
// 设置当前流的位置为流的开始
stream.Seek(0, SeekOrigin.Begin);
doc.LoadXml(Encoding.UTF8.GetString(bytes));