


Detailed explanation of the process of executing Action in .NET MyMVC framework
In the GetHandler method of AjaxHandlerFactory, an ActionHandler will finally be created, which is an HttpHandler, which will be called in the 15th step of the pipeline (quoting the sequence in the blog [Write your own service framework with Asp.net] ).
Note: The GetHandler method of AjaxHandlerFactory is called in step 10. Step 12 is preparing the Session (non-in-process mode). Therefore, the use of Session must be decided before step 12.
All Action codes are executed in ActionHandler:
internal class ActionHandler : IHttpHandler{ internal InvokeInfo InvokeInfo; public void ProcessRequest(HttpContext context) { // 调用核心的工具类,执行Action ActionExecutor.ExecuteAction(context, this.InvokeInfo); }
The implementation process of ExecuteAction is as follows:
internal static void ExecuteAction(HttpContext context, InvokeInfo vkInfo) { if( context == null ) throw new ArgumentNullException("context"); if( vkInfo == null ) throw new ArgumentNullException("vkInfo"); // 调用方法 object result = ExecuteActionInternal(context, vkInfo); // 设置OutputCache OutputCacheAttribute outputCache = vkInfo.GetOutputCacheSetting(); if( outputCache != null ) outputCache.SetResponseCache(context); // 处理方法的返回结果 IActionResult executeResult = result as IActionResult; if( executeResult != null ) { executeResult.Ouput(context); } else { if( result != null ) { // 普通类型结果 context.Response.ContentType = "text/plain"; context.Response.Write(result.ToString()); } } }internal static object ExecuteActionInternal(HttpContext context, InvokeInfo info) { // 准备要传给调用方法的参数 object[] parameters = GetActionCallParameters(context, info.Action); // 调用方法 if( info.Action.HasReturn ) return info.Action.MethodInfo.Invoke(info.Instance, parameters); else { info.Action.MethodInfo.Invoke(info.Instance, parameters); return null; } }
Didn’t I mention the timing of calling SetResponseCache() before? , this opportunity is here: after executing the Action.
After setting the OutputCache, it is time to process the return value.
In the previous code, there is another important call:
// 准备要传给调用方法的参数object[] parameters = GetActionCallParameters(context, info.Action);
[Related recommendations]
1. Special recommendation: "php Programmer Toolbox" V0.1 version download
3. Entry-level .NET MVC example
4. Detailed explanation of the process of finding Action in the MyMVC box
5 . .NET MyMVC framework tutorial on how to handle return values
6. .NET MyMVC framework tutorial on how to assign values to methods
The above is the detailed content of Detailed explanation of the process of executing Action in .NET MyMVC framework. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

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

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

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

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. !

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

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.

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

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
