当我将模型传递给MVC中的webapi方法
时,我得到stackoverflowexception这是C#中的模型:
public class Cartoon
{
public long Id { get; set; }
public string Title { get; set; }
public string ImageURL { get; set; }
public DateTime? PublishedDateTime { get; set; }
}
这是我的baseapicontroller中的方法,它在获取数据后往往会回溯一些东西:
[AcceptVerbs("GET", "POST")]
public bool StoreCartoon1(Cartoon cartoon)
{
try
{
return true;
}
catch (Exception e)
{
throw e;
return false;
}
}
Ajax Call:
var cartoonModel = new Object();
cartoonModel.Id = "1";
cartoonModel.Title = "Sourabh";
cartoonModel.ImageURL = "/something.jpg";
var URL = '/api/testApi/StoreCartoon1';
$.ajax({
type: "POST",
dataType: "json",
url: URL,
data: cartoonModel,
success: function (data) { ShowStatusBar('cartoon added successfully'); },
error: function (a, b, c) {
// alert('error ' + a.responseText + ' ' + b + ' ' + c);
//hideLoadingImage();
//jsonValue = jQuery.parseJSON(error.responseText);
//jError('An error has occurred while saving the new part source: ' + jsonValue, { TimeShown: 3000 });
}
});