How to read httpWebRequest's request stream in c#, I got error“ the stream is not readable”?

Your question is unclear If you're trying to read an HttpWebRequest s request stream after other code has written to the stream (a POST request), it's not possible. (The stream is sent directly to the server and is not stored in memory) Instead, you'll need to expose your own MemoryStream, then write it to the HttpWebRequest's request stream wen you're ready to send the request.

Your question is unclear. If you're trying to read an HttpWebRequest's request stream after other code has written to the stream (a POST request), it's not possible. (The stream is sent directly to the server and is not stored in memory) Instead, you'll need to expose your own MemoryStream, then write it to the HttpWebRequest's request stream wen you're ready to send the request.

Try using Fiddler. Worked for me. Fiddler: is a Web Debugging Proxy logs all HTTP(S) traffic between your computer and the Internet allows you to inspect all HTTP(S) traffic, set breakpoints, and "fiddle" with data is freeware can debug traffic from all almost all apps (web browsers and more).

Take a look at this article from code project it should help.

The "stream is not readable" will result if there is an error return code, like 404, 503, 401, and so on. It's likely you haven't checked your status code. Something like this works if the content is text: public string DownloadString(string uri, out int status) { string result= null; status = 0; HttpWebResponse response= null; try { HttpWebRequest request = (HttpWebRequest) HttpWebRequest.

Create(uri); // augment the request here: headers (Referer, User-Agent, etc) // CookieContainer, Accept, etc. Response= (HttpWebResponse) request.GetResponse(); Encoding responseEncoding = Encoding. GetEncoding(response. CharacterSet); using (StreamReader sr = new StreamReader(response.

GetResponseStream(), responseEncoding)) { result = sr.ReadToEnd(); } status = (int) response. StatusCode; } catch (WebException wexc1) { // any statusCode other than 200 gets caught here if(wexc1. Status == WebExceptionStatus.

ProtocolError) { // can also get the decription: // ((HttpWebResponse)wexc1. Response). StatusDescription; status = (int) ((HttpWebResponse)wexc1.

Response). StatusCode; } } finally { if (response! = null) response.Close(); } return result; }.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions