From Jquery I want to call an ActionResult from a controller, but it does not arrive. That ActionResult does not belong to any view, I just want to change a data in BBDD. How could I get it?
The error that the javascript console leaves:
Failed to load resource: the server responded to a status of 500 (Internal Server Error)
Here I leave the code.
$(".abrirCorreo").click(function () {
var id = $(this).attr("id");
var miUrl = '@Url.Action("Confirmacion", "Correo")'
$.ajax({
url: miUrl,
method: "post",
data: id,
success: function (response) {
},
async: true
});
})
[HttpPost]
public ActionResult Confirmacion(int idCorreo)
{
DBEntities db = new DBEntities();
Correo correo = db.Correo.Where(a => a.IdCorreo == idCorreo).First();
if (!correo.Leido)
{
correo.Leido = true;
db.SaveChanges();
}
return View();
}