Am I sending data to WCF using the method suggested in the Best way to support "application / x-www-form-urlencoded" send data using WCF?
I follow the example http://blogs.southworks.net/erossetto/2007/09/03/raw-http-post-with-wcf/ and everything looks fine. However, one problem is with the flow control in the request. I created a helper method like
public static NameValueCollection ParsePOSTRequest(Stream input)
{
StreamReader sr = new StreamReader(input);
string s = sr.ReadToEnd();
sr.Dispose();
return HttpUtility.ParseQueryString(s);
}
I call this in all my methods, so I can more easily find the parameters. Now I noticed a problem when trying to access request information through WebOperationContext.Current. Any property or method simply throws an exception, for example The System.ServiceModel.Channels.MessageProperties object has been disposed., which, apparently, is due to the fact that the stream reader is in front of my business logic.
Question: "Is it right to dispose of?" Should I just just close it? Or do not even bother at all? Is the structure still in need of this thread after my method finishes or all mine to play with?
source
share