當我查看我的迴應我有我的JSON數據,但在底部我已經得到了頁面的HTML?我試圖創建一個JSON響應任何顯而易見的地方。我所做的只是創建一個空白的.aspx頁面。C#試圖創建JSON響應,但得到它的HTML
protected void Page_Load(object sender, EventArgs e){ Database db = DatabaseFactory.CreateDatabase();
DbCommand cmd = db.GetStoredProcCommand("sp_GET_FEED");
db.AddInParameter(cmd, "@FEED_TYPE_ID", DbType.Int32, 1);
List<NewsItem> _NewsItems = new List<NewsItem>() ;
using (IDataReader r = db.ExecuteReader(cmd))
{
while (r.Read())
{
NewsItem i = new NewsItem();
i.id = r["FEED_ID"].ToString();
i.title = r["TITLE"].ToString();
i.fulltext = r["BODY"].ToString();
i.image = r["IMAGE_URL"].ToString();
i.created = r["DATE_CREATED"].ToString();
i.url = r["URL"].ToString();
_NewsItems.Add(i);
}
}
string json = JsonConvert.SerializeObject(_NewsItems);
//Response.Clear();
Response.AddHeader("Content-type", "text/json");
Response.AddHeader("Content-type", "application/json");
Response.ContentType = "application/json";
Response.Write(json);}
所以我resposne是
/////////////////////////////// JSON輸出看起來正確//////////////////////////////
< html> balhhhh我不需要我的迴應作爲它應該是JSON數據的提要。 </HTML>