C# 使用';加载资源失败:服务器响应状态为500';

C# 使用';加载资源失败:服务器响应状态为500';,c#,ajax,C#,Ajax,我创建了一个执行ajax调用的函数,但在C#中调用GetTempData方法时出现了以下错误: 这是我的代码: function restoreDatas() { $.ajax({ url: "/AddRecipe/GetTempData", type: 'GET', dataType: 'json', contentType: 'application/json',

我创建了一个执行ajax调用的函数,但在C#中调用GetTempData方法时出现了以下错误:

这是我的代码:

function restoreDatas() {
        $.ajax({
            url: "/AddRecipe/GetTempData",
            type: 'GET',
            dataType: 'json',
            contentType: 'application/json',
            cache: false,
            processData: false,
            success: function (result) {

            }
        });
    }
ajax调用调用的C#方法:

public ActionResult GetTempData()
    {
        return Json(
        new
        {
            title = Session["title"],
            cookingTime = Session["cookingTime"],
            preparationTime = Session["preparationTime"],
            IngredientList = Session["IngredientList"],
            ingredientsDescription = Session["ingredientsDescription"],
            nbPersons = Session["nbPersons"],
            Category = Session["Category"],
            difficulty = Session["difficulty"],
            nbStars = Session["nbStars"],
            file = Session["file"]
        }, JsonRequestBehavior.AllowGet
            );
    }
我看不出问题出在哪里

你有什么解决办法吗


谢谢

在浏览器中打开开发者工具,查看请求/响应。例如,在Chrome中,按F12键打开开发者控制台,进入网络选项卡。请尝试再次调用GetTempData方法。您将在网络选项卡中看到一个条目,该条目对应于GetTempData请求,并以红色突出显示。如果您单击该按钮,您将能够看到有关您的请求和响应的详细信息


HTH

您使用的是什么版本的mvc?路由设置如何?我创建了一个示例项目,并成功地访问了服务器。另外,在开发工具中,响应说了什么,有时它会给你一个更详细的消息。我在sharepoint中遇到了同样的问题,并通过开发人员模式f12捕捉到了这个错误,这个答案对我没有帮助
public ActionResult GetTempData()
    {
        return Json(
        new
        {
            title = Session["title"],
            cookingTime = Session["cookingTime"],
            preparationTime = Session["preparationTime"],
            IngredientList = Session["IngredientList"],
            ingredientsDescription = Session["ingredientsDescription"],
            nbPersons = Session["nbPersons"],
            Category = Session["Category"],
            difficulty = Session["difficulty"],
            nbStars = Session["nbStars"],
            file = Session["file"]
        }, JsonRequestBehavior.AllowGet
            );
    }