C # Summary of MVC simple learning

Source: Internet
Author: User

The following is a summary of the Controller processing process in different layers:
1. Page handling process
Send request-> UrlRoutingModule capture request-> MvcRouteHandler. GetHttpHandler ()->

MvcHandler. ProcessRequest ()

2. MvcHandler. ProcessRequest () processing process:
Use the factory method to obtain the specific Controller-> Controller. Execute ()-> release the Controller object

3. Controller. Execute () Processing Process
Get Action-> call Action method to get returned ActionResult-> call ActionResult. ExecuteResult () method

4. ActionResult. ExecuteResult () Processing Process
Get IView object-> Get Page Class Based on the Page path in the IView object-> call IView. RenderView () method (Internal call

Page. RenderView method)

Through the analysis of the MVC source code, we know that the role of the Controller object is to pass data and obtain the View object (implementing the IView Interface

Class) to display the notification View object.

The View object is displayed. Although the displayed method RenderView () is called by the Controller, the Controller is only"

The role of the commander, the specific display logic is still in the View object.

Note the relationship between the IView interface and the specific ViewPage. IView objects exist between the Controller and View.

The ASP. NET Program provides the WebFormView object to implement the IView interface. WebFormView is responsible for obtaining specific Page classes based on the virtual directory.

Call Page. RenderView ().

 

Class Name abstract class parent class function
ContentResult indicates the data content based on the content type and encoding.
EmptyResult empty method.
FileResult abstract writes the file content. The specific writing method is in the derived class.
FileContentResult FileResult writes a file through the file byte.
FilePathResult FileResult writes files through the file path.
FileStreamResult FileResult writes files through the file Stream.
HttpUnauthorizedResult throw a 401 error.
JavaScriptResult returns a javascript file
JsonResult returns data in Json format
RedirectResult uses Response. Redirect to Redirect the page
RedirectToRouteResult redirects the page according to the Route rule
ViewResultBase abstract call IView. Render ()
PartialViewResult ViewResultBase calls the ExecuteResult method of the parent class ViewResultBase.
Override the FindView method of the parent class.
Search for the user control. ascx File
ViewResult ViewResultBase calls the ExecuteResult method of the parent class ViewResultBase.
Override the FindView method of the parent class.
Search for the page. aspx File

 

 

 

 

Specific lifecycle of a Filter
This is a piece of official station data.

OnActionExecuting from the controller virtual method.

OnActionExecuting applied to the Filter of the current Controller:

First execute the base class, and then execute
Execute the OnActionExecuting sequence of the filters applied to the Action:

First execute the base class, and then execute

Action Method

The execution sequence of OnActionExecuted applied to the Filter of Action

First execute the derived class, and then execute
OnActionExecuted Method Applied to the Filter of the Current Controller

First execute the derived class, and then execute
OnActionExecuted

 

 

Introduction
System. Web. Routing-This namespace provides a class for URL Routing, through which you can use a URL not mapped to a physical file

IRouteHandler-route handler interface, which must be implemented by custom route handlers
RequestContext-encapsulate information about the requested route and the current http Context
RouteData-information about the requested route
RouteCollection-Route Set
RouteValueDictionary-case-insensitive key/value dictionary table
Route-Route related information

 

 

 

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.