A circular reference was detected while serializing an object of type 'System.Reflection.RuntimeModule'. MVC

0

When I save some data in the BD, this error comes back to me

  

A circular reference was detected while serializing an object of type   'System.Reflection.RuntimeModule'.

It is through an Ajax petition

 $.ajax({
        type: 'POST',
        url: 'uri',
        data: JSON.stringify({
            datosFactura: datos
        }),
        dataType: 'json',
        contentType: 'application/json',
        error: function (xhr) {
            alert("error " + xhr)
        },
        success: function (data) {

            if(data === 1){
                alert("Guardado")
            }
            else{
                alert("No")
            }
        }

And in my controller

        [HttpPost]
        public JsonResult Agregar(DatosFactura datosFactura)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    db.DatosFactura.Add(datosFactura);
                    db.SaveChanges();
                    return Json(1);
                }
                catch (Exception ex)
                {
                    return Json(ex);
                }
            }
            return Json(0);
        }

The error that appears in the browser (Note that it is what is returned from the Catch)

    
asked by Daisuke Dany 02.09.2018 в 01:18
source

0 answers