weixin_33716557 2019-07-29 13:47 采纳率: 0%
浏览 98

VB.NET:未知的Web方法

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);
        }
    });
});
  • 写回答

1条回答 默认 最新

  • weixin_33682719 2019-07-29 16:07
    关注

    Actually by changing framework from 3.5 to 4.6 the problem seems to be solved.

    评论

报告相同问题?

悬赏问题

  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办
  • ¥15 kylin启动报错log4j类冲突
  • ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大
  • ¥15 import arcpy出现importing _arcgisscripting 找不到相关程序
  • ¥15 onvif+openssl,vs2022编译openssl64
  • ¥15 iOS 自定义输入法-第三方输入法
  • ¥15 很想要一个很好的答案或提示