使用’无法加载资源的Ajax调用:服务器响应状态为500′

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

Failed to load resource: the server responded with a status of 500 (Internal Server Error) 

这是我的代码:

 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