Json 作为JsonResult 时出错
Json 作为JsonResult 时出错。
$.ajax({ url: "../../Tracks/QueryCalendarViews", cache: true, //type: "post", success: function (doc) { var events = []; $(doc).find('event').each(function () { events.push({ title: $(this).attr('TrackContent'), start: $(this).attr('TrackDate') // will be parsed }); }); } });
System.InvalidOperationException: This request has been blocked because sensitive information could be disclosed to third party web sites when this is used in a GET request. To allow GET requests, set JsonRequestBehavior to AllowGet.
由错误信息可知MVC2出于对网站数据的保护,默认禁止通过get的请求返回JsonResult数据,你可以在返回Json时,传入第二个参数 JsonRequestBehavior.AllowGet,如:return Json(result, JsonRequestBehavior.AllowGet),当然你也可以修改你的前端代码,使用post的方式来获取数据。