我試圖在我的網頁中轉換一些xml代碼。所以我試圖使用json.net。 所有的工作,直到我試圖顯示我的字符串你好。我的aspx.cs網站看起來是這樣的:ASP.NET json.Net xml到json
aspx.cs
public partial class json : System.Web.UI.Page
{
public class Account
{
public string Name { get; set; }
public string Email { get; set; }
public DateTime DOB { get; set; }
}
public void Page_Load(object sender, EventArgs e)
{
Account account = new Account
{
Name = "John Doe",
Email = "[email protected]",
DOB = new DateTime(1980, 2, 20, 0, 0, 0, DateTimeKind.Utc),
};
string hello = JsonConvert.SerializeObject(account, Formatting.Indented);
}
}
而且我的aspx網站看起來是這樣的。
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="json.aspx.cs" Inherits="json" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div><% = this.hello %></div>
</form>
</body>
</html>
我該怎麼做,我可以使用字符串「你好」。
感謝,並有一個美好的一天:d
什麼是你的錯誤或異常? –
嚴重\t代碼\t說明\t項目\t文件\t線\t抑制狀態 錯誤\t CS1061「json_aspx」不包含「你好」的定義,並沒有擴展方法「你好」,接受類型「json_aspx」的第一個參數可以發現(您是否缺少使用指令或程序集參考?)\t json – Doggo