Loading...

MVC model view controller overview

MVC is a framework methodology that divides an application implementation into three component roles: models, views, and controllers.


Models in a MVC based application are the components of the application that are responsible for maintaining state. Often this state is persisted inside a database (for example: we might have a EmployeeClass that is used to represent order data from the Employee table inside SQL).

Views in a MVC based application are the components responsible for displaying the application’s user interface. Typically this UI is created off of the model data (for example: we might create an Employee [Edit] view that surfaces textboxes, dropdowns and checkboxes based on the current state of a Employee object).

Controllers in a MVC based application are the components responsible for handling end user interaction, manipulating the model, and ultimately choosing a view to render to display UI. In a MVCapplication the view is only about displaying information – it is the controller that handles and responds to user input and interaction.

Advantages of using MVC Framework


1. It provides a clean separation of concerns between UI and model.
2. UI can be unit test thus automating UI testing.
3. Better reuse of views and model. You can have multiple views which can point to the same model andalso vice versa.
4. Code is better organized.

The MVC pattern helps you create applications that separate the different aspects of the application (input logic, business logic, and UI logic), while providing a loose coupling between these elements. The pattern specifies where each kind of logic should be located in the application. The UI logic belongs in the view. Input logic belongs in the controller. Business logic belongs in the model. This separation helps you manage complexity when you build an application, because it enables you to focus on one aspect of the implementation at a time.For example, you can focus on the view without depending on the business logic.

In addition to managing complexity, the MVC pattern makes it easier to test applications than it is to test a WebForms-based ASP.NET Web application. For example, in a Web Forms-based ASP.NET Web application, a single class is used both to display output and to respond to user input. Writing automated tests for Web Forms- based ASP.NET applications can be complex, because to test an individual page, you must instantiate the page class, all its child controls, and additional dependent classes in the application. Because so many classes are in instantiated to run the page, it can be hard to write tests that focus exclusively on individual parts of the application. Tests for Web Forms-based ASP.NET applications can therefore be more difficult to implement than tests in an MVC application. Moreover, tests in a Web Forms-based ASP.NET application require a Webserver. The MVC framework decouples the components and makes heavy use of interfaces, which makes it possible to test individual components in isolation from the rest of the framework.

The loose coupling between the three main components of an MVC application also promotes parallel development. For instance, one developer can work on the view, a second developer can work on the controller logic, and a third developer can focus on the business logic in the model.


Razor View Engine


Razor view engine is a new view engine created with ASP.Net MVC model using specially designed Razor parser to render the HTML out of dynamic server side code. It allows us to write Compact,Expressive, Clean and Fluid code with new syntax's to include server side code in to HTML


ASP.NET MVC namespaces and classes


ASP.NET MVC namespaces and classes are located in the System.Web.Mvc assembly.

System.Web.Mvc contains classes and interfaces that support the MVC pattern for ASP.NET Web applications. This namespace includes classes that represent controllers, controller factories, action results, views, partial views, and model binders

System.Web.Mvc.Ajax namespace contains classes that support Ajax scripts in an ASP.NET MVC application. The namespace includes support for Ajax scripts and Ajax option settings.

System.Web.Mvc.Async namespace contains classes and interfaces that support asynchronous actions in an ASP.NET MVC application

System.Web.Mvc.Html namespace contains classes that help render HTML controls in an MVC application. The namespace includes classes that support forms, input controls, links, partial views, and validation.

Following process are performed by ASP.Net MVC page:
1) App initialization
2) Routing
3) Instantiate and execute controller
4) Locate and invoke controller action
5) Instantiate and render view.





Hope you will find this helpful. Feel free to provide your comments.

Facebook tips to write your status or comment in blue text

I like facebook very much and always try to be in touch with my friend using facebook. One of my new friend Manish has teach me hot to write my status or comment in blue text which I am sharing with you. I hope you like it.

Want to Write YOUR Status/Comment in Blue Text:
Copy and Paste This On Your Wall:
@+@+[0:[120251138048541:0: "YOUR TEXT" ]+]
...
Replace "YOUR TEXT"
with whatever you want to write in "BLUE"...

"And Remove all the "+" signs."

It works only on profile walls not in groups.
Older Posts

Contact Me

© Copyright Source Code World | Designed By Code Nirvana
Back To Top