Quantcast
Channel: Fluent Validation for .NET
Viewing all articles
Browse latest Browse all 1917

New Post: Web API 2

$
0
0
So I spent several hours stepping through the WebApi code to try and figure out what was going on, and unfortunately I can't find a way around it.

Looking at the code for JQueryMvcFormUrlEncodedFormatter, it seems that when creating the model binder it completely disregards all configured values and creates a new HttpConfiguration (in FormDataCollectionExtensions.ReadAs in the WebApi source). Because of this, it seems impossible to customize the validation behaviour, because even though I can swap out components in the Services collection, these are completely ignored by the time that model binding occurs. I can't begin to imagine why this design decision was taken.

So basically I'm stuck - I can't find another way around this without changing the mvc source code.

Viewing all articles
Browse latest Browse all 1917

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>