Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Silverlight 4.0 - HttpWebRequest throwing ProtocolViolationException

I am getting a "System.Net.ProtocolViolationException: Operation is not valid due to the current state of the object." error when trying to call

 var request = (HttpWebRequest)WebRequest.Create(uri);

 request.Method = "GET";

 request.ContentType = "text/xml";

 request.BeginGetRequestStream(RequestCompleted, request);
like image 900
cmaduro Avatar asked May 03 '26 16:05

cmaduro


1 Answers

I suspect this may be because you are performing a BeginGetRequestStream on a request object for which you have specified the "GET" method.

When performing a "GET" the server will not be expecting an entity body in the request hence you should proceed straight to BeginGetResponse. Also specifying a ContentType on the request is not necessary, it specifies the type of content being sent in the entity body of the request but as stated a "GET" doesn't send any content it only gets content.

like image 162
AnthonyWJones Avatar answered May 05 '26 09:05

AnthonyWJones