Home Backend Development C#.Net Tutorial Detailed explanation of the process of finding Action in MyMVC box

Detailed explanation of the process of finding Action in MyMVC box

May 17, 2017 am 11:30 AM
action

First, we need to register MyMVC's HttpHandlerFactory in web.config, which is the entrance to the entire framework.
In the ASP.NET pipeline process, the GetHandler() method will be called, and finally my code has a chance to run!
The first line of code executed by the framework is:

// 根据请求路径,定位到要执行的ActionControllerActionPair pair = UrlParser.ParseAjaxUrl(virtualPath);
Copy after login
public sealed class ControllerActionPair{    public string Controller;    public string Action;}
静态方法UrlParser.ParseAjaxUrl()就是专门用来解析URL并返回ControllerActionPair的:
Copy after login

The code is very simple. The core is actually the regular expression, which extracts the Controller from the URL and the name of the Action depends on it.
As for the use of regular expressions, I think this is a basic skill and will be skipped here.

Let’s look at the second call of AjaxHandlerFactory:

// 获取内部表示的调用信息InvokeInfo vkInfo = ReflectionHelper.GetAjaxInvokeInfo(pair);
Copy after login

The ReflectionHelper class is an internal tool class specifically used for reflection processing. The relevant code for the AjaxAction search process is as follows (note the Comments):

The above is the 4 pieces of code related to AjaxAction search:
1. In the static constructor of ReflectionHelper, I loaded All AjaxControllers.
2. The GetAjaxController method is used to return the type description of a Controller based on its name.
3. The GetAjaxAction method is used to return Action description information based on the type of Controller and the name of the Action to be called.
4. The GetAjaxInvokeInfo method is used to convert the ControllerActionPair description obtained from the AjaxHandlerFactory into more specific description information.

In the code, the search process of Action adopts delayed loading mode. To save the collection of Action description information, I use threadsafetyHashtable

[Related recommendations]

1. Special recommendation: "php Programmer Toolbox" V0.1 version download

2. ASPFree Video Tutorial

3. Entry-level .NET MVC Example

4. . NET MyMVC framework detailed explanation of the process of executing Action

5. .NET MyMVC framework tutorial on how to assign values ​​to methods

6. .NET MyMVC framework tutorial on processing return values

The above is the detailed content of Detailed explanation of the process of finding Action in MyMVC box. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

DJI Osmo Action 5 Pro: Release date mooted as retailer reveals launch pricing that could undercut GoPro Hero 13 Black DJI Osmo Action 5 Pro: Release date mooted as retailer reveals launch pricing that could undercut GoPro Hero 13 Black Sep 04, 2024 am 06:51 AM

DJI has not confirmed any plans to introduce a new action camera yet. Instead, it seems that GoPro will get ahead of its rival this year, having teased that it will introduce two new action cameras on September 4. For context, these are expected to a

New DJI Osmo action camera spotted before probable summer 2024 launch to rival recent GoPro and Insta360 releases New DJI Osmo action camera spotted before probable summer 2024 launch to rival recent GoPro and Insta360 releases Jul 01, 2024 am 09:49 AM

Almost a year has passed since DJI released the Osmo Action 4 (curr. $299 on Amazon). Since then, the company has focused on its other divisions, including new RS camera gimbals. On top of that, it has introduced various drones as well like the Avata

Detailed explanation of Action asynchronous operation of Vuex state management Detailed explanation of Action asynchronous operation of Vuex state management Aug 10, 2022 pm 03:29 PM

In some cases, we want to perform some asynchronous operations in Vuex, such as network requests, which must be asynchronous. How to deal with this situation? Let me introduce to you the Action asynchronous operation of Vuex state management. I hope it will be helpful to friends in need. !

Insta360 Go 3S: New pocketable 4K action camera released weighing just 39 g with Apple Find My support Insta360 Go 3S: New pocketable 4K action camera released weighing just 39 g with Apple Find My support Jun 14, 2024 pm 06:05 PM

Insta360hasreleasedanewactioncamera,itssecondoftheyearaftertheInsta360X4(curr.$499.99onAmazon).Asexpected,thecompanyhasintroducedtheGo3S,anupgradedthatGo3thatadds4Kvideorecordingcapabilities.Specifically,whileInst

GoPro releases new Hero 13 Black action camera with new lens mods alongside curious GoPro Hero GoPro releases new Hero 13 Black action camera with new lens mods alongside curious GoPro Hero Sep 05, 2024 am 06:45 AM

GoPro has now introduced its annual action camera refresh. Unlike in recent years, the company has decided to release two models. However, it has not returned to 360-degree cameras, despite teasing this time last year that it would replace the Max wi

How to implement elasticsearch java client action How to implement elasticsearch java client action May 22, 2023 am 08:43 AM

Most operations in elasticsearch are through corresponding actions, which are in the action package. Its structure is shown in the figure below: The above figure is a partial screenshot of the action package, which corresponds to the actions of each function. The packages of each action are also very similar to index. The implementation of these actions is also very similar. They are all basic self-actions. The following figure shows the inheritance relationship of indexaction: Because these actions do not actually implement the corresponding functions, they are just a proxy, so the implementation is also very simple. Their main function is to provide methods for creating new responses and requests and their corresponding actions.

GoPro Hero: New pocket-sized action camera leaks along with rumoured release date GoPro Hero: New pocket-sized action camera leaks along with rumoured release date Aug 16, 2024 am 09:43 AM

Details of a completely new GoPro action camera has leaked online alongside equivalent information about the Hero 13 Black. Please note that the information contained below is said to originate from an Amazon US listing that has since now been remove

Deal | Amazfit GTR 3 Pro Limited Edition smartwatch with 12-day battery life, GPS and 1,000 nits AMOLED now available for just $125 Deal | Amazfit GTR 3 Pro Limited Edition smartwatch with 12-day battery life, GPS and 1,000 nits AMOLED now available for just $125 Aug 15, 2024 am 11:14 AM

The Amazfit GTR 3 Pro Limited Edition is currently on sale at Amazon for just $124.99, down 40% from its list price of $209.99. Compared to the standard version that has an aluminum case, the Amazfit GTR 3 Pro Limited Edition uses hand-polished stain

See all articles