Base solution for your next web application
Open Closed

Your request is invalid on DTO custom validation. #6053


User avatar
0
tteoh created

Hi, I'm using non-core ASP.NET Zero Version 5.6.0 (ASP.NET MVC 5 & AngularJs 1.x) and also published to Azure.

I kept on getting "Your request is invalid!" on DTO custom validation even though I've set the custom validation error message on it. But I can see the custom validation error message on swagger. No matter on local machine or Azure environment and I've set customErrors mode = "RemoteOnly".

Thanks. /Tommy


12 Answer(s)
  • User Avatar
    0
    maliming created
    Support Team

    What is the response body requested in the chrome developer tools web panel?

  • User Avatar
    0
    tteoh created

    Hi maliming,

    This is what I got:

    {
       "result":null,
       "targetUrl":null,
       "success":false,
       "error":{
          "code":0,
          "message":"Your request is not valid!",
          "details":"The following errors were detected during validation.\r\n - Min and Max must be 0 or blank since Input Type is not Text or Number.\r\n",
          "validationErrors":[
             {
                "message":"Min and Max must be 0 or blank since Input Type is not Text or Number.",
                "members":null
             }
          ]
       },
       "unAuthorizedRequest":false,
       "__abp":true
    }
    

    What I wanted to show is:

    Min and Max must be 0 or blank since Input Type is not Text or Number.

    Instead of:

    Your request is invalid!

    Thanks. /Tommy

  • User Avatar
    0
    maliming created
    Support Team

    I can't reproduce the problem you encountered.

  • User Avatar
    0
    tteoh created

    Hi maliming,

    Is there any setting or configuration related to this?

    Thanks. /Tommy

  • User Avatar
    0
    maliming created
    Support Team

    Should be showing the error message here, you can set breakpoint debugging to see,

    https://github.com/aspnetzero/aspnet-zero/blob/dev/src/MyCompanyName.AbpZeroTemplate.Web/Abp/Framework/scripts/libs/angularjs/abp.ng.js#L34

  • User Avatar
    0
    tteoh created

    Hi maliming,

    Where to set the breakpoint? DTO or the js file?

    When I add in console.log(error); to that function, it shows nothing when the error occurred.

    Thanks. /Tommy

  • User Avatar
    0
    maliming created
    Support Team

    In js file. see abp.ng.js:

    https://github.com/aspnetzero/aspnet-zero/blob/dev/src/MyCompanyName.AbpZeroTemplate.Web/Abp/Framework/scripts/libs/angularjs/abp.ng.js#L99

    https://github.com/aspnetzero/aspnet-zero/blob/dev/src/MyCompanyName.AbpZeroTemplate.Web/Abp/Framework/scripts/libs/angularjs/abp.ng.js#L34

  • User Avatar
    0
    tteoh created

    Hi maliming,

    It's not hitting the breakpoint.

    Thanks. /Tommy

  • User Avatar
    0
    maliming created
    Support Team

    Can you use the Demo project to reproduce the problem you are experiencing? Demo project:https://aspnetzero.com/Download

  • User Avatar
    0
    tteoh created

    Hi maliming,

    With latest version or the same version as mine now?

    Thanks. /Tommy

  • User Avatar
    0
    tteoh created

    Hi maliming,

    The problem is solved.

    This is happening is because my colleague did some changes to the 400 status code error and he just remembered that he did changes to it.

    Sorry and thank you helping me.

    Thanks. /Tommy

  • User Avatar
    0
    maliming created
    Support Team

    You're welcome, my friend