title: Reading the response stream of a WebException
body: <p>I have the following method which is basically authenticating users with their Facebook credentials. For some reason, I am getting a <code>WebException</code> when trying to process the authorization key (code). So I tried to read the response stream in order to know what is going on but I keep getting errors while reading the stream. Here's my code:</p>
  
  <pre><code>    private void OnAuthCallback(HttpContextWrapper context, WebServerClient client)
      {
          try
          {
              IAuthorizationState authorizationState = client.ProcessUserAuthorization(context.Request);
              AccessToken accessToken = AccessTokenSerializer.Deserialize(authorizationState.AccessToken);
              String username = accessToken.User;
              context.Items[USERNAME] = username;
          }
          catch (ProtocolException e)
          {
              if (e.InnerException != null)
              {
                  String message = e.InnerException.Message;
                  if (e.InnerException is WebException)
                  {
                      WebException exception = (WebException)e.InnerException;
                      var responseStream = exception.Response.GetResponseStream();
                      responseStream.Seek(0, SeekOrigin.Begin);
                      using (StreamReader sr = new StreamReader(responseStream))
                      {
                          message = sr.ReadToEnd();
                      }
                  }
                  EventLog.WriteEntry("OAuth Client", message);
              }
          }
      }
  </code></pre>
  
  <p>If I remove the <code>responseStream.Seek(0, SeekOrigin.Begin);</code> line, it gives me an <code>ArgumentException</code> with a message that says the stream was not readable. And with this line in place, it tells me that I cannot manipulate a stream that was already closed. How was this stream closed? And why can't I read from it?</p>