Table of Content-

  1. What is MVC (Model view controller)?
  2. What are task of each MVC components?
  3. What is namespace for MVC framework?
  4. Can you explain the complete flow of MVC?
  5. Explain Page Life Cycle of ASP.NET MVC
  6. Can we integrate MVC with ASP.NET?
  7. What are features of the ASP.NET MVC Framework?

 

What is MVC (Model view controller)?

Model-View-Controller () framework provides an alternative to the framework, which separates an application into three main components: the model, the view, and the controller (as shown).

What is MVC (Model view controller)

 

Figure 01: Invoking a controller action that expects a parameter value

What are task of each MVC components?

Model- Model objects retrieve and store model state in a database, implement the business logic for the applications.
View-Used to create user interface (UI) from model data.
Controller-handle user interaction, work with the model, and ultimately select a view to render

What is namespace for MVC framework?

The framework is defined in the System.Web. namespace and is a fundamental, supported part of the System.Web namespace.

Can we integrate MVC with ASP.NET ?

Yes, The ASP.NET framework is a lightweight, highly testable presentation framework that (as with Web Forms-based applications) is integrated with existing features, such as master pages and membership-based authentication.

Can you explain the complete flow of MVC?

Tips for Women in the days of menstruation

Page Lifecycle of an ASP.NET MVC:

  1. App initialization- Browser request pages to IIS

  2. Perform routing - IIS will pass this request to Application UrlRoutingMoule will try to find Route defined in RouteTable

  3. Create MVC request handler- UrlRoutingMoule will try to find matching Route defined in RouteTable collection. If matching route found - MvcRouteHandler will create instance of MvcHandler

  4. Controller-

    1. Create controller- MvcHandler will create an instance of controller

    2. Execute controller - MvcHandler calls the controllers Execute method

    3. Invoke action - controller determines which action method of the controller class to call, and then calls that method.

  5. Controller to Model - Controller work with Model- to retrieve and store data, to perform business logic for application.

  6. Model to Controller- Model provides data to controller

  7. Controller to View - Controller execute the result by returning a result type.

  8. View to Controller - View can also directly interact with controller (e.g. while interacting with  multiple modules ).

  9. Return Result to IIS - Appropriate return type based on action will be returned to IIS.

  10. Return to Browser -Render result to Browser

What are features of the ASP.NET MVC Framework?

  1. Separation of application tasks -Easy to Manage - Manage complexity by dividing an application into the model, the view, and the controller

  1. Full control over the behavior of an application - as it doesn't use view state or server-based forms which will give full control to developer.

  1. Better support for test-driven development (TDD)- Easy to Test

  2. Best suited for large team

  3. An extensible and pluggable framework- You can plug in your own view engine, URL routing policy, action-method parameter serialization, and other components. The ASP.NET MVC framework also supports the use of Dependency Injection (DI) and Inversion of Control (IOC) container models.  DI allows you to inject objects into a class, instead of relying on the class to create the object itself. IOC specifies that if an object requires another object, the first objects should get the second object from an outside source such as a configuration file.

  1. Powerful URL-mapping component- URL's are comprehensible and searchable URLs.

  1. Support for existing markup - ASP.NET page (.aspx files), user control (.ascx files), and master page (.master files)

  1. Support for existing ASP.NET features- nested master pages, in-line expressions (<%= %>), declarative server controls, templates, data-binding, localization, forms authentication and Windows authentication, URL authorization, membership and roles, output and data caching, session and profile state management, health monitoring, the configuration system, and the provider architecture.