My ajax:
$.ajax({
url: '/Extensions/Sample',
type: 'GET',
async: false,
dataType: 'text',
processData: false,
//contentType: 'application/json; charset=utf-8',
data: "extension=" + JSON.stringify(newextension),
success: function (data) {
alert("Success");
}
}).error(function (jqXHR, textStatus, errorThrown) {
alert(jqXHR.status);
alert(jqXHR.responseText);
alert(errorThrown);
});
My Controller:
public ActionResult Sample(Extension extension)
{
return PartialView(extension);
}
My Model:
public class Extension
{
public int Id { get; set; }
public string Name { get; set; }
public string Number { get; set; }
}
My Json :
newextension = [{
'Name': 'User1',
'Number': '101'
},
{
'Name': 'User2',
'Number': '102'
},
{
'Name': 'User3',
'Number': '103'
}];
The error is Object reference not set to an instance of an object. where is the mistake and how can i resolve this issue . Any help ..