post string value as text/plain content type using httpwebrequest RRS feed

  • Question

  • User600779293 posted


    I want to post only string values in newwebrequest without using any stream writer in the getrequest. As am posting

    data to the Jersey based services which only accept getresponseastring.

    How could I do it in .Net web application OR any other way of oing it like with HTTp Client ?


    Any Idea would be most welcome.

    Thursday, October 20, 2011 7:07 AM

All replies

  • User1622957740 posted

    Any data POSTed with HttpWebRequest requires streams. The data sent is always a binary stream which happens to be encoded as a string. Stream, string, file it all is data as far HttpWebRequest is concerned.

    You can use also use System.Net WebClient.UploadString() to do simple data sends which is much easier.

    +++ Rick ---

    Friday, October 21, 2011 5:47 PM
  • User600779293 posted

    HI I tried the webclient when I use its uploadstring method then It throws

    Internal server error 500 Response

     string response = client.UploadString("", null, "rajnish");

    WHY so.!!

    Monday, October 24, 2011 7:46 AM