I am trying to post a list of JSON objects to a controller, I have been trying to follow this post Passing A List Of Objects Into An MVC Controller Method Using jQuery Ajax However I get an error in the console saying that resource cannot be found even though the action is in the controller and I am passing it the right parameters and so the action method does not get hit on the breakpoint.
[HttpPost]
    public ActionResult EditWidget(List<SaveWidgetModel> widget)
    {
        if (ModelState.IsValid)
        {
            foreach (var item in widget) 
            {
                var targetWidget = db.widgets.Where(EditWidget => EditWidget.WidgetCode == item.id).FirstOrDefault();
                targetWidget.x = item.x;
                targetWidget.y = item.y;
                targetWidget.height = item.height;
                targetWidget.width = item.height;
                db.Entry(targetWidget).State = EntityState.Modified;
                db.SaveChanges();
            }
            return RedirectToAction("Index");
        }
        return new EmptyResult();
    }
and here is my javascript code
function SaveDashboard(){
    var gridArray = _.map($('.grid-stack .grid-stack-item:visible'), function (el) {
        el = $(el);
        var gridID = el.find('.grid-stack-item-content.ui-draggable-handle').first().attr('id');
        var node = el.data('_gridstack_node');
        return {
            id: gridID,
            x: node.x,
            y: node.y,
            width: node.width,
            height: node.height
        };
    });
    gridArray = JSON.stringify({ 'widget' : gridArray});
    $.ajax({
        contentType: 'application/json; charset=utf-8',
        dataType: 'json',
        url: 'Dashboard/EditWidgets/',
        type: 'POST',
        data: gridArray,
        success: function (dataset) {
        },
        failure: function (xhr, error) {
            console.log(xhr)
            console.log(error)
        },
    });
}
 
     
     
    