문제

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.

도움이 되었습니까?

해결책

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

다른 팁

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(),
    };
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top