我有一個使用JSON2庫序列化的JavaScript對象。然後我試圖將這個JSON字符串傳遞給一個ASP.net web服務。我已經改變了webmethod嘗試幾個不同的參數配置,但他們都導致'500 - 內部服務器錯誤'如何將JSON發送到Asp.NET Webservice?
有人可以給我一個線索嗎?
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
Web服務:
[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響應中的更多細節。 – tjrobinson 2011-02-24 16:03:23