ASP.NET MVC: Order of execution of ValueProviders
Asked Answered
C

2

8

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

ValueProviders:

  • QueryStringValueProvider
  • RouteDataValueProvider
  • FormValueProvider
  • ...

I did not find an information.

Courtund answered 18/12, 2012 at 16:10 Comment(1)
How about this? ASP.NET MVC / Web API / Web Pages - Source Code aspnetwebstack.codeplex.com/SourceControl/changeset/view/…Epact
V
8

If memory serves me, the priority is like this.

  1. Form data in the request
  2. Route data
  3. Query String
  4. Http File Collection

EDIT I appear to be in agreement with the following website, which lists the same order. http://www.howmvcworks.net/OnModelsAndViewModels/TheBeautyThatIsTheModelBinder

Vicarage answered 18/12, 2012 at 16:13 Comment(0)
S
4

You can check this out from 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(),
    };
Stealth answered 8/11, 2015 at 17:38 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.