Base solution for your next web application
Open Closed

Unexpected AjaxResponse for WepApi #2794


User avatar
0
sergii created

Hi, Could somebody clarify why I get aways "An internal error occurred during your request!" on any kind of exceptions ?

[HttpPost]
public async Task<AjaxResponse> Save()
{
            try
            {
                throw new Exception("Any Exception");
            }
            catch (AbpValidationException ex)
            {
                string message = String.Join(Environment.NewLine, ex.ValidationErrors.Select(x => x.ErrorMessage));
                result = new AjaxResponse(false)
                {
                    Error = new ErrorInfo("Error occurred while verifying form data", message)
                };
            }
            catch (Exception ex)
            {
                result = new AjaxResponse(new ErrorInfo("An error occurred while processing form data", ex.Message));
            }

            return result ?? new AjaxResponse(true);
}
{
__abp: true,
error: {
  code: 0,
  details: null,
  message: "An internal error occurred during your request!",
  validationErrors: null
},
result: null,
success: false,
targetUrl: null ,
unAuthorizedRequest: false}

1 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    If you are using ASP.NET MVC 5.x, you need to set customErrors to On in web.config, see <a class="postlink" href="http://aspnetboilerplate.com/Pages/Documents/Handling-Exceptions#DocEnableErrorHandling">http://aspnetboilerplate.com/Pages/Docu ... orHandling</a>.

    If you are using ASP.NET Core, this is not normal.

    Thanks.