Mvc5-9 Today speak three descriptor

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.