【发布时间】:2015-06-15 22:15:15
【问题描述】:
当我尝试运行时收到500 (Internal Server Error)
$.ajax({
xhr: function() {
var xhr = new window.XMLHttpRequest();
return xhr;
},
type: 'POST',
url: '@Url.Action("MyAction","MyController")',
data: fi,
contentType: "application/json; charset=utf-8",
dataType: "json", // dataType is json format
success: function(retJson) {
// ...
}
});
其中fi 是像{org: "string1", cat: "string2", fileName: "string3"} 这样的JavaScript 映射,而myAction 就像
[HttpPost]
public async Task<JsonResult> myAction (FileInfo fi)
{
FileInfo 由
public class FileInfo
{
public string org { get; set; }
public string cat { get; set; }
public string fileName { get; set; }
}
知道我在这里缺少什么吗?
【问题讨论】:
-
什么是 500 服务器错误?
-
500 响应的堆栈跟踪中的内容是什么,应该提供更多详细信息?
-
JavaScript 控制台打印错误。
-
删除
contentType: "application/json; charset=utf-8",(或者使用data: JSON.stringify(fi),
标签: c# asp.net ajax json asp.net-mvc