0

I have Internal Server Error in response to an Ajax call. The request is sent from a Visual Web Part, inside a solution, towards an application page :

The application page has this method:

 [WebMethod(EnableSession = true)]
        [ScriptMethod(UseHttpGet = true)]
        public static String Creation()
        {
           // do something ...

                return "{\"status\":\"success\"}";

        }

The visual web part makes this JQuery call:

 $.ajax({
                    type: "GET",                    url: "/_layouts/15/PrenCalendarExchange/Registration.aspx/Creation",
                    dataType: 'json',
                    contentType: 'application/json',
                    data: {
                        prenSubject: $('#prenSubject').val()
                        , location: $('#location').val()
                    },
                    error: function (XMLHttpRequest, textStatus, errorThrown) {
                             alert("Error: " + textStatus + " - " + errorThrown);
//INTRNAL SERVER ERROR IS THROWN HERE
                    }
                });

The call works fine in my local environment but fails on a test environment.

1
  • Are you able to access the ULS logs to identify what the internal server error is? Additionally, would you be able to wrap Creation in a try-catch to try and return a string version of the exception, if you're not able to directly debug?
    – Ted N.
    Apr 17, 2015 at 15:32

1 Answer 1

0

I used this syntax and it is working fine:

Application Page:

[System.Web.Services.WebMethod]
public static string myWB()
{
     return "my HTML or JSON"
}

The call from the visual web part is same as yours.
So maybe try to add just [System.Web.Services.WebMethod] to your method.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.