I can't seem to understand how to get a POST to work. My "GET" calls work but my POSTS - I don't get the posted information.
Here's my registered route:
routeManager.MapRoute(
"MyCompany/ToDoList"
,
"{controller}/{action|/{id}"
,
new
{controller =
"ToDo"
, action =
"list"
},
new
{id = @
"\d*"
} ,
new
[] {
"MyCompany.Modules.ToDo.API"
});
In my ToDoController I have:
[DnnAuthorize(AllowAnonymous =
true
)]
[AcceptVerbs(HttpVerbs.Post)]
[ValidateInput(
false
)]
public
ActionResult Save(
int
id, List<ToDoDto> todos)
{
// id is set as value in URL
// todos is ALWAYS null
}
My List<ToDoDto> todos is always null. Here's an example of my posted data:
{
"todos"
: [
{
"title"
:
"afds"
,
"isDone"
:
false
,
"id"
:-1,
"_destroy"
:
false
},
{
"title"
:
"sdd"
,
"isDone"
:
false
,
"id"
:-1,
"_destroy"
:
false
},
{
"title"
:
"fsfe"
,
"isDone"
:
false
,
"id"
:-1,
"_destroy"
:
false
}
]}
Does anyone see what I've done wrong or missed? Or know of a POST example I should work from?
*Edit* I should also note the url I'm calling is like: http://localhost/DesktopModules/MyCompany/ToDoList/API/ToDo/Save/3
So while setting a default to "list" in my routes - I'm calling the Save