0

I am able to successfully call Backbone's HTTP POST and PUT methods and have them link up to my server using Asp.Net MVC.

The problem is that when I call the HTTP DELETE using model.destroy() I get this error...

The parameters dictionary contains a null entry for parameter 'id' of non-nullable type 'System.Int32' for method 'System.Web.Mvc.ActionResult Delete(Int32)' in 'GSASF.Controllers.AdminController'. An optional parameter must be a reference type, a nullable type, or be declared as an optional parameter. Parameter name: parameters

Right before I call model.destroy() I logged the id to the console and it was correct. This is my code. *Note that my model doesn't have a field called id but instead a field called HoverId. The database table already existed so I have to make due.

 Delete: function(id) { if (id) { for (var i = this.collection.length - 1; i >= 0; i--) { var item = this.collection.at(i); if (item.get("HoverId") == id) alert("Item to be destroyed ID: " + item.get("id")); item.destroy(); }; } [ActionName("SpaceToolTipEdit")] [HttpDelete] public ActionResult Delete(int id) { var imageHover = sr.GetImageHoverById(id); if (imageHover != null) { sr.DeleteImageHover(imageHover); return new HttpStatusCodeResult(200); } return new EmptyResult(); } 

1 Answer 1

1

Ok, I feel dumb now.

The solution was all to simple. I had originally set the url attribute to my /{Controller}/{SpaceToolTipEdit} url. I was supposed to set this to the urlRoot attribute instead.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.