Actually i'm trying to make a simple test webservice that send sms messages using Twiling, the function where i send the message is a webmethod which i call from AJAX.
The issue is that i'm getting error 500 and it says that webmethod SendSMS is unknown.
[ArgumentException: Metodo Web SendSMS sconosciuto.
Nome parametro: methodName]
System.Web.Script.Services.WebServiceData.GetMethodData(String methodName) +178
System.Web.Handlers.ScriptModule.OnPostAcquireRequestState(Object sender, EventArgs eventArgs) +202
System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +144
System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step) +50
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +73
Debug even doesn't reach the webmethod, here is the code
Partial Class _Default
Inherits System.Web.UI.Page
<WebMethod>
<ScriptMethod(ResponseFormat:=ResponseFormat.Json)>
Sub SendSMS(ByVal numero As String, ByVal messaggio As String)
Const accountSid = "XXX"
Const authToken = "XXX"
TwilioClient.Init(accountSid, authToken)
Dim toNumber = New PhoneNumber(numero)
Dim message = MessageResource.Create(
toNumber, from:=New PhoneNumber("+XXX"),
body:=messaggio)
Console.WriteLine(message.Sid)
End Sub
End Class
While here is the js code
$('#send').click(() => {
var numero = $('#telefono').val();
var messaggio = $('#messaggio').val();
$.ajax({
type: "POST",
url: "Default.aspx/SendSMS",
data: JSON.stringify({ numero: numero, messaggio: messaggio }),
contentType: "application/json; charset=utf-8",
dataType: "json",
complete: function (xhr, textStatus) {
alert('OK');
},
error: function (xhr, status, errorThrown) {
alert(errorThrown);
}
});
});