I'm trying to return simple Json data back from a standard WebForm. It sounds very dumb, but I actually need this to happen. I'm using MVC, and this is one of only 3 pages that I use that is NOT an MVC view. Otherwise, I'd write a controller to return Json(myData), but I can't do that.
Here is what I'm doing:
var serializer = new JavaScriptSerializer();
var json = serializer.Serialize(someObject);
HttpContext.Current.Response.ContentType = "application/json";
HttpContext.Current.Response.Write(json);
HttpContext.Current.Response.End();
However, I keep getting a browser dialog asking me to do with the webpage, meaning it's trying to download the page... ?
What am I missing?