我有一个运行HttpHandler类的Web服务。在这个类中,我检查了表单/查询字符串参数的请求流。在某些情况下,似乎这些参数没有通过。经过一番挖掘,我发现了一些我不太明白的行为。见下:奇数HttpRequest行为
// The request contains 'a=1&b=2&c=3' // TEST ONLY: Read the entire request string contents; using (StreamReader sr = new StreamReader(context.Request.InputStream)) { contents = sr.ReadToEnd(); } // Here 'contents' is usually correct - containing 'a=1&b=2&c=3'. Sometimes it is empty. string a = context.Request["a"]; // Here, a = null, regardless of whether the 'contents' variable above is correct
任何人都可以向我解释为什么这可能会发生?如果这有什么区别,我正在使用.NET WebClient和UploadDataAsync在客户端上执行请求。
如果您需要更多信息,请让我知道。
为什么不使用'context.Request.QueryString'? – 2010-03-26 17:06:34