0

I'm trying to call a function in my .aspx.cs, and it works fine until it is deployed. I have several method calls, but this is the only one giving me the 500 error. I've searched everywhere but can't seem to find an appropriate solution.

function NewEmail(){
    alertify.confirm('Envío de correo', 'El formulario de envío se abrirá en una nueva ventana', function () {
    $.ajax({
        type: 'POST',
        url: "Priority.aspx/getTrackingNumber",
        data: {},
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function (response) {
            //some code here
        }
    });
}, function () { alertify.error('Envío de correo cancelado') }).set('labels', { ok: 'Abrir formulario', cancel: 'Cancelar' });
}

and this is the code in my .aspx.cs file

[WebMethod, ScriptMethod(ResponseFormat = ResponseFormat.Json, UseHttpGet = false)]
public static string getTrackingNumber()
{
    //code here
}
wazz
  • 4,953
  • 5
  • 20
  • 34
  • Have you checked error logs. It seems like that getTrackingNumber method is called but then some server-side (500) error occurs inside your method. Ensure that all the dependencies e.g. database are deployed. – Mohsin Mehmood May 21 '18 at 19:51
  • Before deployment it works just fine, getting a 200 OK, and works as expected. The webmethod is returning what it is supposed to return. The only thing I get is Unknown web method getTrackingNumber. Parameter name: methodName Description: An unhandled exception occurred during the execution of the current web request. Exception Details: System.ArgumentException: Unknown web method obtenerTracking. Parameter name: methodName An unhandled exception was generated during the execution of the current web request. – Carlos Serret May 21 '18 at 20:19
  • Weird! Is there any javascript errors in browser console? Do you have any other WebMethods defined on the same page which are working fine? Also, ensure you have scriptmanager or scriptproxymanager added on your page – Mohsin Mehmood May 21 '18 at 20:45
  • Yes, I have multiple WebMethods, but this is the only one not working. And no, no JS errors in browser console. I mean, only the one I copied above. – Carlos Serret May 21 '18 at 21:32
  • So all other web methods defined in the same .aspx.cs file have static modifier applied as well? – Mohsin Mehmood May 21 '18 at 21:37
  • You're calling a *page* method, not a web service? The method is in the page's code behind, yes? Just checking. Is the ScriptManager set to do page methods? – wazz May 22 '18 at 01:53
  • Yes, I'm sorry, I only have page methods, they're in the code behind. About the scriptmanager set to do page methods I'm not sure. But this is the only one not working, the rest of them work just fine after deployment. @wazz – Carlos Serret May 22 '18 at 19:51
  • @CarlosSerret is it possible to share code of getTrackingNumber method code? Also, have you tried moving this method out to a new test page containing only this method? – Mohsin Mehmood May 23 '18 at 16:59
  • the code inside the method is irrelevant, I've run it with the actual code AND without it (everything commented), and it keeps throwing the same error. And no, I haven't tried it on a test page. – Carlos Serret May 25 '18 at 14:44

0 Answers0