为什么我不能返回Json。它被加下划线并且在当前情况下不存在。未识别Json类型
using System;
using System.Collections.Generic;
using System.Net;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using System.Web.Http;
using System.Web.Http.Results;
using System.Web.Mvc;
//class and namespace detail removed to keep this post short
public async Task<IHttpActionResult> Post(string url, StringContent data, Dictionary<string, string> headers)
{
using (var client = new HttpClient())
{
var response = await client.PostAsync(url, data);
var result = await response.Content.ReadAsStringAsync();
//the line below is the error********
return Json(new { HttpStatusCode = HttpStatusCode.OK });
}
}
我也试过install-package System.Json
,这并没有帮助。
我知道有可能是其他的东西错了,因为我在一个小时前开始,但从未工作过的代码,我不明白为什么Json
无法识别
这是从类库中(如果有关系)
该方法是任何类或命名空间之外定义!? –
@PeterBons,对不起。不,我只是删除了,以保持短小。更新以清楚说明。对不起 – MyDaftQuestions