我在我的控制器中有这个;为什么这会抛出一个内部服务器错误
public JsonResult Json_GetStoreList()
{
StoresData stores = new StoresData();
return Json(stores.All());
}
然后在我的部分观点中,我有这个;
$(function() {
$.ajax({
url: '/Maintenance/Json_GetStoreList',
dataType: 'json',
success: function (data) {
alert(data);
},
error: function (xhr, ajaxOptions, thrownError) {
alert(xhr.status);
alert(thrownError);
}
});
});
控制器正在返回名为Store的对象的IEnumerable列表,它看起来像这样;
public class Store
{
public Guid id { get; set; }
public int number { get; set; }
public string name { get; set; }
}
的JavaScript抛出错误
500 - 内部服务器错误
放在服务器方法一个破发点,看看什么东西扔。使用Fiddler2并观察请求流量并在500错误响应中使用web视图,您将看到.Net异常页面。 – asawyer 2013-05-02 04:06:43
尝试添加此contentType:'application/json – TGH 2013-05-02 04:06:47
可能是一个异常,调试并捕获它,以便我们现在可以做到这一点。 – 2013-05-02 04:07:00