What is asp.net MVC - A small tutorial

What is asp.net MVC 

What is asp.net MVC the model view controller it is better to separate an application into three main components.

The model
The view
The controller 

What is asp.net MVC

The ASP.net MVC Framework provide an alternative to the asp.net webform pattern for creating web application the ASP.net MVC framework is a lightweight, highly testable presentation framework that is integrated with existing asp.net features, such as master page and membership based authentication. The MVC Framework is defined in the System.web.mvc assembly . Full control over HTML JavaScript and css it is better as well as recommended approach for large scale application where different teams are working together.

Asp.Net Mvc reference namespace

System.Web.Mvc: Contains class and interfaces that support the MVC pattern for ASP.net web application. This namespace includes classes that represent controllers, controller factories, action results,views, partial views and model model binders

System.Web.Mvc.Ajax: Contains classes that support ajax script in an ASP.net MVC application. That namespace includes support for ajax script and ajax option settings

System.Web.Mvc.Async: Contains classes and interfaces that support asynchronous action in an ASP.net MVC application.

System.Web.Mvc.Html: Contents classes that helper render HTML control in an MVC application. The namespace includes classes that support forms, input control, links, partial view and validation.

MVC Architechture

An ASP.net MVC application have three main folders which is model,view and Controller and also be have more folder to place script file and App_Start and much more so let's talk about these folders.


Model is used to store Data classes which is created by SQL or entity framework or may be reference of service from WCF or many more at last we just use model to represent the data schema for a view or partial view.


View folder is used to store the view page or partial view page for a particular Action is declared into controller class, Basically view folder maybe contains a shared Folder also in which we can store to common pages or user control that can be used into any controller every request for a view or partial view page from an Action method is also check the page extension into shared folder also.


Controller is just used to store some business logic class controller is a collection of only classes and every class is a child class of System.Web.Mvc.Controller class, a controller class is only contain some method known as Action method which is responsible to return a View, Partial view, Content JSON Data and much more.

Action method in asp.net MVC

Action method are the only a special type of method which is used write the code for a particular task and after that is also responsible to returns something to the user and that can be a page or partial page any action handle the two type of http request.

1.Http Get 
2.Http Post 

Http Get: Http Get action is only used to handle this request are come directly from user and also we can say those request come at first time for an Action method.

Http Post: Http Post action is only call call at that time when any already you exist on client side and user will submit an HTML form by Anthony submit type button so at the time that type of action will call and that can also written the all control value in Form Collection type object from HTML form 

An action method may use type of return type to return different-different type of info or value to the user we have some many type of returned from an action to user but maximum time we will use Action Result because it's a parent type any other type which can be used in an action method as a return type 

Action Result is an abstract class that can have serval subtype

Action Result SubTypes:

ViewResult: Renders a specified for the user.
EmptyResult: An empty response returned.

PartialViewResult: Renders a specified partial view to the response stream. 
RedirectToRouteResult: Perform Http redirection to URL that is determined by the routing engine based on given route data.

Jason result: serial as a given view data object to JSON format.
JavaScriptResult : Return a piece of JavaScript code that can be executed on the client side.

ContentResult: Write content to the response stream without requiring and view.
FileContentResult: Returns a file to the client.
FileStreamResult: Written a file to the client which is provided by a string. 

Advantage of asp.net MVC framework

1. It makes very easy to manage complexity by dividing an application into the model ,view and the       controller.
2. It does not use Viewstate or server side forms.
3. Full control over HTML JavaScript and css.
4. It provides better support for test driven development(TDD).
5. It works well for web application that are supported by large team of developer and for web designer who need a high degree of control over the application behaviour.
6. By default support of Facebook and Google authentication.
7. It easy to manage ilaj application to dividing in multiple areas.

Read More: