【发布时间】:2011-07-03 16:27:09
【问题描述】:
我有一个使用 JSON2 库序列化的 javascript 对象。然后我试图将此 JSON 字符串传递给 ASP.net Web 服务。我已更改 web 方法以尝试几种不同的参数配置,但它们都导致“500 - 内部服务器错误”
谁能给我一个线索?
function postDataToService(data) {
$.ajax({
url: "http://localhost:2686/DataCollectionService.asmx/StoreDataOut",
type: "POST",
contentType: "application/json; charset=utf-8",
data: data,
success: showSuccessNotice,
error: showFailureNotice,
dataType: "json"
});
} //postdatatoservice
function convertDataToJSON(jsObj) {
return JSON.stringify({ list: jsObj });
} //converdatatojson
网络服务:
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
[System.Web.Script.Services.ScriptService]
public class DataCollectionService : WebService
{
[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public string StoreDataOut(List<string> list)
{
return "Complete";
//model functionality
}
}
【问题讨论】:
-
您可以查看事件日志以获取异常的详细信息吗?或者使用 Fiddler 或 Firebug 在 500 响应中检查更多详细信息。
标签: javascript jquery asp.net ajax json