返回JsonResult会出现Server 500错误?

Sea*_*son 3 c# json asp.net-mvc-2

首次尝试MVC.试图返回JsonResult.我在我的控制器中有这个:

[AcceptVerbs(HttpVerbs.Get)]
public JsonResult GetHistoricalReports()
{
    JsonResult result = Json("test");
    //JsonResult result = Json(DashboardSessionRepository.Instance.HistoricalReports);

    return result;
}
Run Code Online (Sandbox Code Playgroud)

在我看来:

function OnHistoricalListBoxLoad(historicalListBox) {
    $.getJSON('GetHistoricalReports', function (data) {
        alert(data);
    }
Run Code Online (Sandbox Code Playgroud)

我在GetHistoricalReports中设置了一个断点,它确实被击中了.但是,OnHistoricalListBoxLoad中的警报永远不会显示.

Joh*_*rer 6

您需要返回结果,如:

return Json("test", JsonRequestBehavior.AllowGet)
Run Code Online (Sandbox Code Playgroud)