How to disable binding of the route values in ASP.NET MVC?

后端 未结 2 1542
悲哀的现实
悲哀的现实 2021-01-14 10:30

As I know ValueProviderDictionary takes values for binding from 3 places

  1. From Post form
  2. From Route values
  3. From Query string

I

2条回答
  •  时光说笑
    2021-01-14 11:15

    Override Controller.Initialize() and set the ValueProvider property in that method (after calling base.Initialize()).

    To avoid reimplementing the entire ValueProviderDictionary, you could just subclass it. The only interesting part is that you'd have to copy a small snippet of ValueProviderDictionary.PopulateDictionary(). In your constructor, call the base constructor, then immediately this.Clear(), followed by this.YourCustomPopulateDictionary(). This should make your code much smaller.

提交回复
热议问题