我有以下响应代码。当调用 Messagebox.sohw() 方法显示代码:200 时,我在 System.Windows.ni.dll 中发生了类似“System.UnauthorizedAccessException”类型的异常但未在用户代码错误中处理的错误。我的 Json 就像 {"meta":{"code":200}}
private void ReadWebRequestCallback(IAsyncResult ar)
{
HttpWebRequest myReq = (HttpWebRequest)ar.AsyncState;
HttpWebResponse myResponse = (HttpWebResponse)myReq.EndGetResponse(ar);
uritext.Text = myResponse.ResponseUri.ToString();
using (StreamReader httpwebStreamReader = new StreamReader(myResponse.GetResponseStream()))
{
string results = httpwebStreamReader.ReadToEnd();
}
myResponse.Close();
var root = JsonConvert.DeserializeObject<RootObject>(jsondata);
String codenum = root.meta.code.ToString();
Messagebox.sohw(codenum);
}
public class Meta
{
public int code { get; set; }
}
public class RootObject
{
public Meta meta { get; set; }
}