Me aparece el error 500 Internal Server Error
Este es mi Web method
[WebMethod]
public static string EliminarDocumento(int IdDocumento)
{
string mensaje = "";
bool resultado = false;
using (var db = new ContratosEntities())
{
using (var tran = db.Database.BeginTransaction())
{
try
{
var reg = db.Cat_FormatoLiberados.Find(IdDocumento);
reg.Activo = false;
reg.FechaModifico = DateTime.Now;
db.Entry(reg).CurrentValues.SetValues(reg);
db.SaveChanges();
tran.Commit();
resultado = true;
}
catch (Exception ex)
{
mensaje = ex.Message;
resultado = false;
tran.Rollback();
}
}
}
return JsonConvert.SerializeObject(new { Mensaje = mensaje, Resultado = resultado });
}
y mi funcion JS, el web method esta dentro de la carpeta Catalogos
function eliminarCampoAceptar() {
var IdDocumento = $("#idToErase").val();
if ($('#hdnIdContrato').val() == 0) {
for (var i = 0; i < nuevosCampos.length; i++) {
if (idCampo == nuevosCampos[i].IdCampo) {
nuevosCampos.splice(i, 1);
i = nuevosCampos.length + 10;
}
}
$('#tbl-Campos tbody tr#campo-' + idCampo).remove();
} else {
$.ajax({
url: '../Catalogos/FormatosLiberados.aspx/EliminarDocumento',
data: "{ 'IdDocumento': " + IdDocumento + " }",
contentType: 'application/json;charset=utf-8',
dataType: 'json',
success: function (response) {
if (response != null) {
var data = JSON.parse(response.d);
if (data.Resultado) {
$('#tbl-Formatos tbody tr#campo-' + IdDocumento).remove();
}
}
},
method: 'POST'
});
}
}
Ni siquiera llega a la funcion del web method al mandarla llamar La url es correcta que puede faltar?
(Texto extra sin relevancia alguna porque no me deja publicar la pregunta
********************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************)