I asked a question yesterday where it was closed with duplication reason, However I still did not get an answer how to resolve my issue and i need some assistance.
I am using ASP.NET with script manager
<asp:ScriptManager ID="ScriptManager1" EnablePageMethods="true" EnablePartialRendering="true" runat="server" />
I am getting error 500 when trying to post data to server.
Bad code with Error 500:
CS:
[WebMethod]
public static void SetCurrentBaseVersion(string id)
{
// need to get here
}
JS:
function postNewBaseLine() {
var id = "300";
$.ajax({
type: "POST",
url: "ManagerBaseKit.aspx/SetCurrentBaseVersion",
contentType: "application/json; charset=utf-8",
dataType: "json",
data: {'id' :id},
success: function (data) {
alert('success!');
},
statusCode: {
500: function () {
alert('got error 500');
}
}
});
}
What I found so far that if I remove the string id in the webmethod it is working fine and I am being able to reach the SetCurrentBaseVersion (not getting error 500)
Working Code:
CS
[WebMethod]
public static void SetCurrentBaseVersion() //removed the string id
{
// need to get here
}
JS
function postNewBaseLine(id) {
var id = "300";
$.ajax({
type: "POST",
url: "ManagerBaseKit.aspx/SetCurrentBaseVersion",
contentType: "application/json; charset=utf-8",
dataType: "json",
//data: {'id' :id}, removed the data
success: function (data) {
alert('success!');
},
statusCode: {
500: function () {
alert('got error 500');
}
}
});
}