You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
LS,
I have a Net 8 api project with an ApiController with the following method
[HttpGet("{companyName}/{groupName}")]
public async Task<IActionResult> GetData([FromRoute] string companyName, [FromRoute] string groupName)
I have FluentValidationAutoValidation configured just as the example in the ReadMe, so with
// Disable the built-in .NET model (data annotations) validation.
configuration.DisableBuiltInModelValidation = true;
// Only validate controllers decorated with the FluentValidationAutoValidation attribute.
configuration.ValidationStrategy = ValidationStrategy.Annotations;
The ApiControler has not been decorated with the [FluentValidationAutoValidation] attribute.
When calling the api, I get a 400 error. In the logging I see:
...
Microsoft.AspNetCore.Mvc.ModelBinding.ParameterBinder: Debug: Done attempting to validate the bound parameter 'companyName' of type 'System.String'.
...
Microsoft.AspNetCore.Mvc.ModelBinding.ParameterBinder: Debug: Done attempting to validate the bound parameter 'groupName' of type 'System.String'.
...
Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker: Trace: Action Filter: Before executing OnActionExecuting on filter Microsoft.AspNetCore.Mvc.ModelBinding.UnsupportedContentTypeFilter.
Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker: Trace: Action Filter: After executing OnActionExecuting on filter Microsoft.AspNetCore.Mvc.ModelBinding.UnsupportedContentTypeFilter.
Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker: Trace: Action Filter: Before executing OnActionExecutionAsync on filter SharpGrip.FluentValidation.AutoValidation.Mvc.Filters.FluentValidationAutoValidationActionFilter.
Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker: Trace: Action Filter: Before executing OnActionExecuting on filter Microsoft.AspNetCore.Mvc.Infrastructure.ModelStateInvalidFilter.
Microsoft.AspNetCore.Mvc.Infrastructure.ModelStateInvalidFilter: Debug: The request has model state errors, returning an error response.
Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker: Trace: Action Filter: After executing OnActionExecuting on filter Microsoft.AspNetCore.Mvc.Infrastructure.ModelStateInvalidFilter.
Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker: Debug: Request was short circuited at action filter 'Microsoft.AspNetCore.Mvc.Infrastructure.ModelStateInvalidFilter'.
Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker: Trace: Action Filter: After executing OnActionExecutionAsync on filter SharpGrip.FluentValidation.AutoValidation.Mvc.Filters.FluentValidationAutoValidationActionFilter.
Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker: Trace: Action Filter: Before executing OnActionExecuted on filter Microsoft.AspNetCore.Mvc.ModelBinding.UnsupportedContentTypeFilter.
Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker: Trace: Action Filter: After executing OnActionExecuted on filter Microsoft.AspNetCore.Mvc.ModelBinding.UnsupportedContentTypeFilter.
Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker: Trace: Result Filter: Before executing OnResultExecuting on filter Microsoft.AspNetCore.Mvc.Infrastructure.ClientErrorResultFilter.
Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker: Trace: Result Filter: After executing OnResultExecuting on filter Microsoft.AspNetCore.Mvc.Infrastructure.ClientErrorResultFilter.
Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker: Trace: Result Filter: Before executing OnResultExecuting on filter Microsoft.AspNetCore.Mvc.ProducesAttribute.
Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker: Trace: Result Filter: After executing OnResultExecuting on filter Microsoft.AspNetCore.Mvc.ProducesAttribute.
Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker: Trace: Before executing action result Microsoft.AspNetCore.Mvc.BadRequestObjectResult.
So somehow the default MVC ModelStateInvalidFilter now determines that the model is invalid.
If I set DisableBuiltInModelValidation to false, this behavior disappears.
Any ideas?
Thanks,
David.
The text was updated successfully, but these errors were encountered:
Hi @mvdgun ,
Version 1.3.0 of SharpGrip.FluentValidation.AutoValidation.Mvc and FluentValidation.AspNetCore Version 11.3.0".
David-Mulder-at-VLK
changed the title
Net8 FuluentAutovalidation and the default ModelStateInvalidFilter
Net8 FluentAutovalidation and the default ModelStateInvalidFilter
Oct 16, 2023
LS,
I have a Net 8 api project with an ApiController with the following method
I have FluentValidationAutoValidation configured just as the example in the ReadMe, so with
The ApiControler has not been decorated with the [FluentValidationAutoValidation] attribute.
When calling the api, I get a 400 error. In the logging I see:
So somehow the default MVC ModelStateInvalidFilter now determines that the model is invalid.
If I set DisableBuiltInModelValidation to false, this behavior disappears.
Any ideas?
Thanks,
David.
The text was updated successfully, but these errors were encountered: