void DoRequestCallback() { try { using (var endGetResponse = Request.EndGetResponse(responseAsyncResult)) { if (Request.Method == "get" || Request.Method == "post") { using (var responseStream = endGetResponse.GetResponseStream()) { ReadFromResponse(responseStream); return; } } } ReadFromResponse(null); } catch (WebException webException) { if (webException.IsNotFound()) { ReadFromResponse(null); return; } string remoteError; if ( webException.TryReadRemoteError(out remoteError)) { var remoteException = new RemoteException(remoteError, webException); ExceptionCallback(remoteException); } else { ExceptionCallback(webException); } } catch (Exception exception) { ExceptionCallback(exception); } }
void DoRequestCallback() { try { using (var endGetResponse = Request.EndGetResponse(responseAsyncResult)) { if (Request.Method == "get" || Request.Method == "post") { using (var responseStream = endGetResponse.GetResponseStream()) { ReadFromResponse(responseStream); return; } } } ReadFromResponse(null); } catch (WebException webException) { if (webException.IsNotFound()) { ReadFromResponse(null); return; } string remoteError; if (webException.TryReadRemoteError(out remoteError)) { var remoteException = new RemoteException(remoteError, webException); ExceptionCallback(remoteException); } else { ExceptionCallback(webException); } } catch (Exception exception) { ExceptionCallback(exception); } }