Hi, Could somebody help to understand why any AbpValidationException is returned as html for the conntroller method call like below ?
public class ExampleController : AbpController
{
[HttpPost]
[WrapResult(WrapOnSuccess = true, WrapOnError = true)]
public JsonResult ProcessSubmitAction(MyFormViewModel vm)
{
var response = new AjaxResponse(true);
try
{
// my logic here
}
catch (Exception ex)
{
response.Success = false;
response.Error = new Abp.Web.Models.ErrorInfo(ex.Message);
}
return Json(response);
}
}
public class MyFormViewModel
{
[Required(AllowEmptyStrings = false, ErrorMessage = ValidationMessages.EmailRequired)]
[StringLength(Abp.Authorization.Users.AbpUserBase.MaxEmailAddressLength, ErrorMessage = ValidationMessages.EmailLengthExceeded)]
[EmailAddress(ErrorMessage = ValidationMessages.EmailFormatInvalid)]
[DataType(DataType.EmailAddress)]
public string Email { get; set; }
public string ReturnUrl { get; set; }
}
$http.post('Example/ProcessSubmitAction', { Email: 'invalidemailvalue' })
.then(onSuccess, onError)
.finally(onFinished);
3 Answer(s)
-
0
Hi,
It might be the same case with this one <a class="postlink" href="https://github.com/aspnetboilerplate/aspnetboilerplate/issues/1154">https://github.com/aspnetboilerplate/as ... ssues/1154</a>.
-
0
Yes, this is it. Why customErrors setting change content type of a response? - this this unexpected behavior for UI. Developers should switch off custom errors to check appropriate response handlers... not very useful.
-
0
Hi,
ABP handles errors only when customErrors are enabled, this is the way of MVC. See <a class="postlink" href="http://aspnetboilerplate.com/Pages/Documents/Handling-Exceptions">http://aspnetboilerplate.com/Pages/Docu ... Exceptions</a>