asp.net mvc 4 - Delete method with array type as parameter showing null value -
i calling web-api method delete array type parameter, showing value null
. why?
i passing data : data: "arrmenuid"+ jsarraymenuid,
function performalldeletemenu() { if (confirm('are sure want delete menu?')) { var jsarraymenuid = new array(); $("input:checked").each(function () { //console.log($(this).val()); //works fine jsarraymenuid.push($(this).val()); }); alert(jsarraymenuid); $.ajax({ url: '/api/menuwebapi/deleteallmenu/', type: 'delete', contenttype: 'application/json; charset=utf-8', data: "arrmenuid"+ jsarraymenuid, success: function (data) { if (data.success == true) { //getmenulist(); } }, error: function (xhr, textstatus, errorthrown) { //window.location = jserroraction; }, headers: { 'requestverificationtoken': jstokenheadervalue } }); } return false; } public httpresponsemessage deleteallmenu(array arrmenuid) { }
here arrmenuid showing null values.
if 1 have solution, please let me know.
try changing
data: "arrmenuid"+ jsarraymenuid,
to
data: {arrmenuid : jsarraymenuid.join()}
and changing
public httpresponsemessage deleteallmenu(array arrmenuid)
to
public httpresponsemessage deleteallmenu(string arrmenuid)
i don't think javascript array translate c# array , changing instead passing string. once have comma delimited string can make array in c#
Comments
Post a Comment