<p>Hi All,</p>
<p>In My View I have the following code:</p>
My Controller Has:Code:$.ajax({ type: 'POST', url: '/PolicyZone/JsonEditFloatingZone', data: jSonData, contentType: 'application/json; charset=utf-8', dataType: 'json', success: function (response) { window.location.href = response.newLocation; }, error: function (XMLHttpRequest, textStatus, errorThrown) { alert(errorThrown); } });
Now when there is a failure, my controller drops into my exception handler as expected. but in dev,the IDE breaks on the Throw statement with 'exception was unhandled by code' ????Code:public JsonResult JsonEditFloatingZone(string available, string unavailable, int policyZoneID) { string newLocation = string.Concat("../../Edit/", policyZoneID); string failReason = string.Empty; try { PolicyZoneService.EditPolicyZoneFloatingZone(available, unavailable, policyZoneID, ref failReason); if (failReason.Length != 0) { throw new Exception(failReason); } return new JsonResult { Data = new { newLocation } }; } catch (Exception ex) { throw; } }
so that is my first problem. The next is rather than have the Alert show the error's, i'd like to update the ValidationSummary control instead.
Normally to do this, I'd pass the viewModel, use a ModelStateDictionary and add my error to this. However, in my Json call, I am not passing the model, so I dont have that luxury


Reply With Quote