Response.content.readasstringasync() zum ObjektC#

Ein Treffpunkt für C#-Programmierer
Anonymous
 Response.content.readasstringasync() zum Objekt

Post by Anonymous »

Mein Problem ist, dass ich ein von einer API gesendetes Objekt nicht extrahieren kann, obwohl ich das Schema des Objekts entweder in der API oder im Client habe. Mein Code:

Code: Select all

 public async Task Index()
{
HttpClient client = new HttpClient();

Uri baseAddress = new Uri("http://localhost:44237/");
client.BaseAddress = baseAddress;

HttpResponseMessage response = client.GetAsync("api/Front/Subm?IdSubmission=1xxx").Result;

try
{
if (response.IsSuccessStatusCode)
{

string Result = await response.Content.ReadAsStringAsync();
JavaScriptSerializer jsonSerializer = new JavaScriptSerializer();
Submission sub = JsonConvert.DeserializeObject(Result);

return View(sub);
}
else
{

}
}
catch (Exception e)
{

}
}
Die im Ergebnis erhaltene Struktur ist
Image

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post