爲什麼我不能返回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