Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. .NET (Core and Framework)
  4. HttpContent.ReadAsStringAsync

HttpContent.ReadAsStringAsync

Scheduled Pinned Locked Moved .NET (Core and Framework)
3 Posts 2 Posters 147 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    TimWallace
    wrote last edited by
    #1

    I am wondering if I am misunderstanding what HttpContent.ReadAsStringAsync is supposed to return.

    I have an HttpPost that expects to receive a response with data in the Body (there is a reason behind this, but that is not what I want to discuss here). When I get the successful HttpResponseMessage, calling HttpResponseMessage.Content.ReadAsStringAsync() is returning a deserialized JSON object that contains all of the properties of HttpResponseMessage. The Uri being called initially is definitely setting the HttpResponseMessage.Content to a valid StringContent object.

    Is my understanding incorrect, or is ReadAsStringAsync() not behaving as it is supposed to?

    1 Reply Last reply
    0
    • Richard DeemingR Offline
      Richard DeemingR Offline
      Richard Deeming
      wrote last edited by
      #2

      Your understanding is correct. It sounds like a problem with the server code. For example, you've got an endpoint declared as returning an IActionResult, and it returns an HttpResponseMessage object.

      This SO thread might point you in the right direction.

      "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

      T 1 Reply Last reply
      2
      • Richard DeemingR Richard Deeming

        Your understanding is correct. It sounds like a problem with the server code. For example, you've got an endpoint declared as returning an IActionResult, and it returns an HttpResponseMessage object.

        This SO thread might point you in the right direction.

        T Offline
        T Offline
        TimWallace
        wrote last edited by
        #3

        @Richard-Deeming said in HttpContent.ReadAsStringAsync:

        Your understanding is correct. It sounds like a problem with the server code. For example, you've got an endpoint declared as returning an IActionResult, and it returns an HttpResponseMessage object.

        This SO thread might point you in the right direction.

        This turned out to be the problem. Thanks for your post.

        1 Reply Last reply
        1
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups