Loading ...

ASP.NET ProtocolViolationException: Content-Length or Chunked Encoding cannot be set for an operation that does not write data. | CodeAsp.Net

ASP.NET ProtocolViolationException: Content-Length or Chunked Encoding cannot be set for an operation that does not write data.

 /5
0 (0votes)

I saw a post on forums where user was facing the following error. Content-Length or Chunked Encoding cannot be set for an operation that does not write data. 
He was having the following code:

var myRequest = (HttpWebRequest)WebRequest.Create(serviceUrl);
myRequest.Method = "GET";
myRequest.ContentLength = 512; 

Since the request was of GET type it cannot have the request's content length. The fix of the above issue was to remove the following line myRequest.ContentLength = 512; . I hope this will help someone.
 

Comments (no comments yet)

Top Posts