Controllerdescriptor, Actiondescriptor, Parmaterdescriptor
Look at the name of a crazy, what is this? Don't underestimate them, they play a particularly important role in MVC.
Thinking, we can use a variety of useful pre-defined features in MVC (attribute) to achieve great features, such as HttpPost, HttpGet, such as features, but the basic good students must understand that attribute itself will not do anything, but what we do behind it. The story behind it, it's in these three classes.
In fact, these three classes are also not very accurate, because they are abstract classes, and to achieve them is the real story of the protagonist Reflectedactiondescriptor, Reflectedcontrollerdescriptor, Reflectedparmaterdescriptor
Layman
We need to do some preparatory work, because the later content may be a bit around, but we have mastered the core of the pipeline flow, there is no problem.
A request is forwarded by IIS to the application, which is followed by a process. You can see that the Beginexecutecore method is executed after the controller is activated, and the call to Begininvokeaction in this method will check our features.
Urlrouringmodel->mvchandler->controllerfactory (Controller)->actioninvoke (begininvokeaction) Controller[findaction] Check Properties | | Action Check Properties | | Parmater Check Properties –> Actioninvoke execute action
I added some features to it. Debug validation starts below
Confirming the above process, now activate the controller to start entering Beginexecutecore, let's take a look at the method below
Now we have entered the Beginexecutecore, here to execute the Asynccontrolleractioninvoker Begininvokeaction method, everything is the same as the above process, now we go into this method to look at
Now we've seen Controllerdescriptor and Actiondescriptor.
After the constant F11 will enter a Isvalidmethodselector method, here is the action of the attribute method, the method loops through the feature set loop verification,
What happens if the validation fails? will return a actionnotfound see the following two images
The validation and binding of Pramater will continue after the above verification, this method is.
Finally ended, it may be really messy, I hope you see the blog at the same time can be debugging comparison, in the last few verification is best to step by step, while more look at the call stack. In fact, some of the things that go on are asynchronous versions of descriptor, such as Reflectedasynccontrollerdescriptor
Mvc5-9 Today speak three descriptor