I have an ASPX page that I am using to write JSON. It works great in Firefox and Chrome, but when I try and use it in IE 8 it gives me an “The XML page cannot be displayed” error instead of allowing jQuery to load the JSON being written by the response.
Any ideas?
Here is what my code looks like:
protected override void OnLoad(EventArgs e) {
Response.Clear();
Response.ClearHeaders();
Response.ContentType = "application/json";
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.Write(string.Format("[ {{ \"Foo\": \"{0}\", \"bar\": \"{1}\" }} ]", "Foo Content", "Bar Content"));
Response.End();
}
I ended up “fixing” the problem by not specifying a Content Type. Not sure why it didn’t work with the context type as noted above. I’ve used it for other things without a problem.