I work on asp.net mvc . i get error on action result prevent inserting but i don't know what is issue and why not inserting data . code working on my local pc but on server host app iis not work so how to know reason of issue can you please help me add try and catch and display this error on json result
public JsonResult RequesterIndex(ResignationRequester resignationRequester) { dynamic responseData = new ExpandoObject(); responseData.success = false; responseData.message = ""; var filenumber = resignationRequester.EmpID; if (Session[SessionKeys.UserCode] != null) { JDEUtility jde = new JDEUtility(); if (resignationRequester.othersInput != null) { resignationRequester.EmployeeRestrictions = resignationRequester.othersInput; } resignationRequester.DeptCode = Session[SessionKeys.DepartmentCode].ToString(); resignationRequester.EmpID = Convert.ToInt32(Session[SessionKeys.UserCode]); resignationRequester.EmpName = Convert.ToString(Session[SessionKeys.Username]); resignationRequester.Dept = Convert.ToString(Session[SessionKeys.Department]); resignationRequester.Designation = Convert.ToString(Session[SessionKeys.Designation]); resignationRequester.PayGrade = Convert.ToString(Session[SessionKeys.PayGrade]); resignationRequester.CompanyCode = Convert.ToString(Session[SessionKeys.Company]); resignationRequester.Gender = Convert.ToString(Session[SessionKeys.Gender]); resignationRequester.ServiceDuration = Convert.ToString(Session[SessionKeys.ServiceDuration]); int noticeperiod = Convert.ToInt32(Session[SessionKeys.NoticePeriod]); int julianRequestDate = JulianDate.DateTimeToJulian(resignationRequester.LastWorkingDate); int SubmitionDate = JulianDate.DateTimeToJulian((DateTime)Session[SessionKeys.SubmitionDate]); int JoinedDate = JulianDate.DateTimeToJulian((DateTime)Session[SessionKeys.JoinDate]); int storedLastedWorkingDate = JulianDate.DateTimeToJulian((DateTime)Session[SessionKeys.LastWorkingDate]); if (ModelState.IsValid) { responseData.success = true; responseData.message = "Resignation Submission form Created successfully"; } else { responseData.success = false; responseData.message = "Some Required Fields Not Added"; } } else { responseData.success = false; responseData.message = "No Data For This File No"; } return Json(responseData); }
and call action result using ajax requestion with json result
$('#btnsubmit').click(function () { var empidval = $("#txtempid").val(); $("#ResignationApp").submit(function (e) { e.preventDefault(); var formData = $(this).serialize(); $.ajax({ dataType: 'json', url: '@Url.Action("RequesterIndex", "Resignation")', data: formData, success: function (response) { }, error: function (error) { } }); }); });
so how to know issue exception error from your opnion