http://blogs.msdn.com/ksharkey/archive/2004/10/17/243656.aspx
... I just needed a rant space. I've just spent 10-20 minutes trying to track down a bug in some code in a Windows Service I was writing, "Cannot close stream until all bytes are written."
- Get stream length. Yup, right size
- Get ContentLength property. Same
- Write both values side by side to EventLog. Values are identical.
- repeat 'n' times
- Remove ContentEncoding header, assuming it's UTF8. No effect.
- Remove ContentLength header. Works. Autocalculated value is what I was looking for... plus two.
- AAAAAAAAUGH! Change responseWriter.WriteLine to responseWriter.Write. .... grrrr
Sometimes, even .NET easy isn't easy enough for some people.
在使用HttpWebResponse的时候老师报这个错:System.Net.WebException was unhandled
Message="请求被中止: 请求已被取消。"
注释这个就好了,ft
//myHttpWebRequest.ContentLength = indata.Length;