ASP.NET MVC: ValueProviders Execution Order

I like to know the execution order of various ValueProviders in ASP.NET MVC.

ValueProviders:

  • QueryStringValueProvider
  • RouteDataValueProvider
  • FormValueProvider
  • ...

I did not find the information.

+8
c # asp.net-mvc
source share
2 answers

If memory serves me, priority is like that.

  • Form data in the request
  • Route data
  • Query string
  • Http File Collection

EDIT I seem to agree with the following site, which has the same order. http://www.howmvcworks.net/OnModelsAndViewModels/TheBeautyThatIsTheModelBinder

+8
source share

You can check this from the ASP.NET MVC source code: ValueProviderFactories.cs

Here is the predefined order for ValueProviders:

  private static readonly ValueProviderFactoryCollection _factories = new ValueProviderFactoryCollection() { new ChildActionValueProviderFactory(), new FormValueProviderFactory(), new JsonValueProviderFactory(), new RouteDataValueProviderFactory(), new QueryStringValueProviderFactory(), new HttpFileCollectionValueProviderFactory(), }; 
+3
source share

All Articles