“mvc json result the length of the string exceeds…” hatası çözümü
Db’den çektiğiniz verileri servis gibi kullanmak amacıyla Json döndürdüğünüzde alabileceğiniz bir hatadır, çözümü aşağıdaki gibi uygulayabilinir.
[HttpGet]
public JsonResult test()
{
try
{
public List<Barcode> brc = db.Database.SqlQuery<Barcode>("select Barcode from dbo.Test").ToList();
}
catch (Exception)
{
return Json(new HttpStatusCodeResult(HttpStatusCode.NotFound));
}
var jsonResult = Json(brc, "application/json", Encoding.UTF8, JsonRequestBehavior.AllowGet);
jsonResult.MaxJsonLength = int.MaxValue;
return jsonResult;
}