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

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

java - Digest auth with Spring Security using javaconfig -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -