实际应用场景是将http请求的Request.Headers(类型就是NameValueCollection)记录到日志。
10 回答
拉莫斯之舞
TA贡献1820条经验 获得超10个赞
string.Join(",",Request.Headers.AllKeys.SelectMany(Request.Headers.GetValues, (k, v) => new { key = k, value = v }));
慕勒3428872
TA贡献1848条经验 获得超6个赞
先转字典 再json
JsonConvert.SerializeObject(Request.Headers.AllKeys.ToDictionary(k=>k,v=>Request.Headers[v]))
qq_笑_17
TA贡献1818条经验 获得超7个赞
报错:
'NameValueCollection' does not contain a definition for 'Select' and no extension method 'Select' accepting a first argument of type 'NameValueCollection' could be found
- 10 回答
- 0 关注
- 539 浏览
添加回答
举报
0/150
提交
取消