C# HttpClient, getting error Cannot add value because header 'content-type' does not support multiple values -


httpclient serviceclient = new httpclient(); serviceclient.defaultrequestheaders.add("accept", "application/json");  httpcontent content = new stringcontent(text); content.headers.add("content-type", "text/html");  var response = await serviceclient.postasync(new uri(_serviceurl), content); 

this code. want post, , set content type text/html, when above error.

i can set content type seems via content.headers.contenttype don't know how specifcy "text/html" if that. can help?

haven't got .net 4.5 ready, according httpcontentheaders.contenttype , mediatypeheadervalue, should this:

content.headers.contenttype = new mediatypeheadervalue("text/html"); 

Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -