Je cette méthode du contrôleur:ASP.NET MVC JsonResult retour 500
public JsonResult List(int number)
{
var list = new Dictionary<int, string>();
list.Add(1, "one");
list.Add(2, "two");
list.Add(3, "three");
var q = (from h in list
where h.Key == number
select new
{
key = h.Key,
value = h.Value
});
return Json(list);
}
Du côté client, ont ce script jQuery:
$("#radio1").click(function() {
$.ajax({
url: "/Home/List",
dataType: "json",
data: { number: '1' },
success: function (data) { alert(data) },
error: function (xhr) { alert(xhr.status) }
});
});
Je reçois toujours un code d'erreur 500. Quelle est la problème?
Merci
Cela s'applique à ASP.NET MVC 2, correct? L'exigence JsonRequestBehavior.AllowGet a démarré avec la version 2. – JustinStolle