I am facing an issue with my project when I try to run it. Whenever I attempt to run the project, I encounter a 500 internal server error.
Here is a snippet of my code:
Client.cs
public class Client
{
public Client(string firstName, string id, string lastName)
{
FirstName = firstName;
LastName = lastName;
Id = id;
}
[JsonProperty("id")]
public string Id { get; set; }
[JsonProperty("first_name")]
public string FirstName { get; set; }
[JsonProperty("last_name")]
public string LastName { get; set; }
}
In the Regrestion.aspx file, whenever the function Regrestion is called, I consistently receive a 500 error.
<script type="text/javascript" language="javascript">
function Regrestion() {
//get data by document.getElementById...
var d = {
first_name: firstName,
id: id,
last_name: lastName
}
$.ajax({
url: 'Registretion.aspx/AddNewClient',
method: "POST",
contentType: "application/json; charset=utf - 8",
dataType: 'json',
data: JSON.stringify(d),
success: function (flights) {
alert("succ");
}, error: function (error) {
alert("error");
}
});
}
</script>
Code behind Registretion.aspx.cs
public partial class Registretion : System.Web.UI.Page
{
[System.Web.Services.WebMethod(EnableSession = true)]
[System.Web.Script.Services.ScriptMethod]
public static Client AddNewClient(Client c)
{
//more code
return c;
}