I have a javascript object that I serialize using the JSON2 library. Then I try to pass this JSON string to the ASP.net web service. I changed the web method to try several different configurations of parameters, but all of them lead to the error "Internal Server Error" 500.
Can someone give me a hint?
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"
});
}
function convertDataToJSON(jsObj) {
return JSON.stringify({ list: jsObj });
}
Web service:
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
[System.Web.Script.Services.ScriptService]
public class DataCollectionService : WebService
{
[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public string StoreDataOut(List<string> list)
{
return "Complete";
}
}
source
share