I have created a CRUD application using ASP.NET MVC and Syncfusion components. When it gets errors on the database side, I use exception to handle them. After publishing and running the project on IIS, I have no problem running on the server side but client side doesn't receive the exception message correctly.
// ASP.NET MVC controller
try
{
db.SaveChanges();
}
catch (Exception)
{
throw new Exception("Foreign key detected");
}
Object received in the view in server side contains "Foreign key detected" as part of the HTML, but when running on client side default view is passed.
// View script
function failure(args) {
var ER1 = args.error[0].error.responseText.split("Exception:")[1].split('<br>')[0];
alert(ER1);
}