I'm invoking a REST service via http which returns a stream as the response. My client code looks like so:
Uri uri = new Uri(remoteAddress);
var webRequest = (HttpWebRequest)WebRequest.Create(uri);
webRequest.Method = "GET";
webRequest.ContentType = "multipart/mixed";
webRequest.BeginGetResponse(responseResult =>
{
HttpWebResponse response = (HttpWebResponse)webRequest.EndGetResponse(responseResult);
this.messages = ParseResponse(response);
Complete(false);
}, null);
I'm getting the following error on this line:
HttpWebResponse response = (HttpWebResponse)webRequest.EndGetResponse(responseResult);
System.Net.ProtocolViolationException was unhandled by user code Message=Operation is not valid due to the current state of the object. StackTrace: at System.Net.Browser.AsyncHelper.BeginOnUI(SendOrPostCallback beginMethod, Object state) at System.Net.Browser.BrowserHttpWebRequest.EndGetResponse(IAsyncResult asyncResult) at LaharSubProxy.SubscribeAsyncResult`1.<>c__DisplayClass1.b__0(IAsyncResult responseResult) at System.Net.Browser.BrowserHttpWebRequest.<>c__DisplayClassd.b__b(Object state2) at System.Threading.QueueUserWorkItemCallback.WaitCallback_Context(Object state) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx) at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem() at System.Threading.ThreadPoolWorkQueue.Dispatch() at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback() InnerException:
This is driving me absolutely nuts since the exception is not pointing to anything useful. I have enabled the "streaming" option in fiddler but I'm not seeing any traffic/errors.
Please help!