Error 500 when calling ajax to controller - MVC Razor

My controller:

    [HttpGet]
    public ActionResult canEdit(List<string> mylist)
    {
        if (SomeProgramLogic)
        {
            return Content("Y");
        }

        return Content("N");
    }

      

My ajax call:

    var getData = { mylist : myArray}; // An array created in the client side

    $.ajax({
        type: "GET",
        url: "canEdit",
        data: getData,
        success: function (data) {
            alert(data); 
        },
        dataType: "json",
        traditional: true
    });

      

The debugger goes into my controller. mylist contains exact data. Under no circumstances do I see an error or an exception. But I get this error: "Failed to load resource: the server responded with a status of 500 (Internal Server Error) and no warning appears.

My display url format

      http://localhost/Controller/canEdit?mylist=a&mylist=a&mylist=b 

      

+3


source to share


1 answer


I changed the value of the returned controller to

     return Json("N", JsonRequestBehavior.AllowGet); 

      



and that solved the problem. Thanks to @TrueBlueAussie for the pointer.

+2


source







All Articles