调试时看不到httpcontent的值 [英] Cannot see the value of httpcontent when debugging

查看:50
本文介绍了调试时看不到httpcontent的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些代码如下

string Payload =
" {\" case_id \":\" FS-Case-88062659 \",\" stage_name \":\\ \\"Back Office \",\" data \":{\" Outcome \":\" CO \",\" siteResponseDateTime \" :\" 2018-09-13T12:07:32.7798361 + 01:00 \"}}"

string Payload = "{\"case_id\":\"FS-Case-88062659\",\"stage_name\":\"Back Office\",\"data\":{\"Outcome\":\"CO\",\"siteResponseDateTime\":\"2018-09-13T12:07:32.7798361+01:00\"}}"

System.Net.Http.HttpContent httpContent  = new StringContent(Payload,Encoding.UTF8," application / x-www-form-urlencoded");

System.Net.Http.HttpContent httpContent  = new StringContent(Payload, Encoding.UTF8, "application/x-www-form-urlencoded");

//如果我使用" application / json"

// same if I use "application/json"

如果我在visual studio(2015)调试器中查看httpContent ...它的类型对象是System.Net.Http.HttpContent 

If I look at httpContent in the visual studio (2015) debugger... its an object of type System.Net.Http.HttpContent 

标题=  Content-Type:application / x-www-form-urlencoded; charset = utf-8

Headers = Content-Type: application/x-www-form-urlencoded; charset=utf-8

但我在httpContent中看不到任何Payload。

But I cannot see any of the Payload in the httpContent.

我做错了什么?

是否表示标题 - 然后是ContentLength = 153 - 这是 与我的有效载荷相同的长度(如果我删除\字符),但我看不到有效载荷本身....

Is does say Headers - then ContentLength = 153 - which is the  same length as my payload (if I remove the \ chars ), but I cannot see the payload itself....

推荐答案

嗨goofygdog2,

Hi goofygdog2,

我们可以通过名为  ReadAsStringAsync的方法获取相应内容,如下所示:

We could get the contect via the method named ReadAsStringAsync, like this:

string Payload = "{\"case_id\":\"FS-Case-88062659\",\"stage_name\":\"Back Office\",\"data\":{\"Outcome\":\"CO\",\"siteResponseDateTime\":\"2018-09-13T12:07:32.7798361+01:00\"}}";

HttpContent httpContent = new StringContent(Payload, Encoding.UTF8, "application/x-www-form-urlencoded");


string jsonContent = httpContent.ReadAsStringAsync().Result;

致以最诚挚的问候,

张龙


这篇关于调试时看不到httpcontent的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆