Refer to my previous article on Value providers in MVC: Custom Value Providers in MVC. Value Providers are the components that feed data to model binders. Feeding the data means installing the data to the Model binder for further use at the action level.
The framework contains a few built-in value providers named FormValueProvider, RouteDataValueProvider, QueryStringValueProvider and HttpFileCollectionValueProvider that fetch data from Request.Form, Request.QueryString, Request.Files and RouteData.Values.
An idea is very simple as the name implies; Value providers means an agent provides some value for its uses at action level.
This is a solution structure which has CustomHeaderValueProvider as depicted below:

Here is an easy way to create Custom Value Providers.
Each value provider implements an interface IValueProvider that has two methods as shown below in the image:
The ContainsPrefix method is called by the model binder to determine whether the value provider has the data for a given prefix. The GetValue method returns a value for a given data key or returns null if the provider doesn't have any suitable data
After this time to register Value Provider through factory. I’ve created a factory CustomValueProviderFactory to register our CustomHeaderValueProvider as shown in image below. This class has one method which returns calls and returns CustomheaderValueProvider after managing its stuff.
This is the complete code for the CustomHeaderValueProvider and Custom Factory.
Join the conversation! Your thoughts help the community grow.
Sign in to leave a comment
It is the same account you read, post and publish with — and you will come straight back to this page.








Atul RawatPosted Jun 17, 2016, 2:46 AM
nice article sir
Sachin KaliaPosted Apr 25, 2016, 1:52 AM
Thanks Everyone for reading this article.Please share your opinion once you get a chance to run an attached application.
Bhavik PatelPosted Apr 24, 2016, 8:37 PM
Useful
Rahul Kumar SaxenaPosted Apr 24, 2016, 12:20 PM
Good Show
Vignesh ManiPosted Apr 24, 2016, 10:20 AM
Nice
Humayun Kabir MamunPosted Apr 24, 2016, 12:32 AM
Nice...
Bhuvanesh MohankumarPosted Apr 23, 2016, 6:21 PM
good
Kuppurasu NagarajPosted Apr 23, 2016, 1:33 PM
Nice Sharing..