ASP.NET MVC 2 – Echec avec la réponse jquery ajax

Je ne comprends pas cette erreur, ne génère pas d’erreur dans “JsonResult Test ()”, je fais d’autres projets comme ASP.NET MVC

Merci

Erreur:

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. [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.] System.Web.Mvc.JsonResult.ExecuteResult(ControllerContext context) +263733 System.Web.Mvc.ControllerActionInvoker.InvokeActionResult(ControllerContext controllerContext, ActionResult actionResult) +10 System.Web.Mvc.c__DisplayClass14.b__11() +20 System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation) +251 System.Web.Mvc.c__DisplayClass16.b__13() +19 System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 filters, ActionResult actionResult) +178 System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, Ssortingng actionName) +314 System.Web.Mvc.Controller.ExecuteCore() +105 System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) +39 System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestContext requestContext) +7 System.Web.Mvc.c__DisplayClass8.b__4() +34 System.Web.Mvc.Async.c__DisplayClass1.b__0() +21 System.Web.Mvc.Async.c__DisplayClass8`1.b__7(IAsyncResult _) +12 System.Web.Mvc.Async.WrappedAsyncResult`1.End() +59 System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +44 System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +7 System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +8678910 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155 

c #

 using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; namespace Tesis.Controllers { public class AnalysisSourceDataController : Controller { // // GET: /AnalysisSourceData/ public ActionResult Index() { return View(); } public JsonResult Test() { return Json(new { mymsg = "my msg" }); } } } 

javascript

  $(function() { $.getJSON("/AnalysisSourceData/Test", function(data) { alert(data.mymsg); }); });  

qu’est-ce que vous ne comprenez pas? L’erreur pourrait difficilement être plus descriptive. C’est une fonction de sécurité pour empêcher le piratage JSON , vous pouvez le désactiver comme ça ..

  return Json(new { mymsg = "my msg" }, JsonRequestBehavior.AllowGet); 

mais vous devez comprendre les implications .