27Jan

Brief Journey to Asp.Net MVC Framework

Introduction:
 
ASP.NET MVC is a  framework for building web applications that uses the model-view-controllerpattern.
 
Like ASP.NET Web Forms, ASP.NET MVC is also built on top of the ASP.NET Framework. This means we can use
same APIs like security, state management, membership, caching,ajax etc in MVC Applications.
 
Every ASP.NET MVC application has three parts: a model, views, and controllers.
 
Model:
It consists of all the classes that handle data and business logic.
 
Controller:
Data processing using model classes is initiated by the controllers that are in charge of user requests.
 
View
Once the data processing is complete the controller creates a response to the user by sending the results to a View who then produces HTML to be rendered in the browser.
 
 
 
architecture
 
 
 
The model in the MVC pattern represents the parts of the application that implements the data domain logic.
 
It includes classes representing objects in database (ex:Entity Framework data classes,LINQ To SQL data classes).
Views are the components that show users data fromthe model.
 
A view page receives a view model object from the controller. The view page contains HTML (and possibly some UI-related
code) to determine how to render the model data back to the browser.
 
The controllers are classes that collect the user requests, work with the model, and finally select a view to
render the appropriate UI.
 
 
When to Use ASP.NET MVC?
 
 
High level of control over the response HTML: Unlike Web Forms, Views in ASP.NET MVC
render HTML exactly as you tell them.
 
Easier unit testing: With ASP.NET MVC, it is very easy to follow testing patterns such as test-driven development (TDD).
 
Code separation: It refers code separated from one another, as it is divided into model, views, and controllers, which makes it easy to maintain.
 
 
What are the Advantages of ASP.NET MVC?
 
The pattern itself makes it easier to manage complexity by separating the
functionality of the application into three core parts, model, view, and controller.
 
• ASP.NET MVC web applications do not use view state or server-based forms.
 
View state can become very large, which is a problem for devices like smartphones running
over slow networks (transmitting all that information can be very slow). 
 
In a Web Forms page,you could only have one per page. This is quite a major restriction. In MVC, there is no
such restriction—that is, you can have as many elements as you like.
 
• It provides better support for test-driven development (TDD).
 
• It works very well for web applications that are supported by large teams of developers
and for web designers who need a high extent of control over the HTML .
 
 
 
How ASP.NET MVC Process Requests?
 
One of the most important concepts to understand about MVC applications is that no relationship exists between a
page request and a physical file inside the web server.
In a traditional Web Forms and Web Pages application, every
page request is translated into a call to a physical file in the webserver. For example, if your request is something
like http://myapp/mypage.aspx, the web server interprets the request by looking at the root of the website for a file
named mypage.aspx.It then processes the file and returns the generated HTML.
 
In the case of an MVC application, when you makes a request (e.g.,http://myapp/product/list), a component
called routing engine matches the request to a specific route.
 A route defines requests using a pattern string and
establishes the controller and method in the controller class that should process the request. 
Once the route is identified, the routing engine creates a request handler that in turn will create the controller object that will process
the request (in our example, the controller is “product”). The controller then invokes the method in the controller
class that will process the request (in the example is named “list”). These methods in controller classes that process
requests are called action methods.
When the processing of the request ends, the action method produces a result to
send back to the user. Generally the result is some HTML (rendered by a View) the user will see in the browser.
 
 
request processing
 
 

Summary:

So we have learned that what is, when to use, what are the advantages and handling requests of MVC Framework. Thanks for reading.

 
 
 
 

Related

Token Based Authentication for Web API's

Securing ASP.NET Web API using Custom Token Based AuthenticationProviding a security to the Web API&...

Read More >

ASP.NET: Audit Trail Implementation using Entity Framework

When you are working with certain projects which involves the Customer records, you might need to tr...

Read More >

Asynchronous actions in MVC 5

What does it mean?Asynchronous actions allow developers to handle more concurrent requests and can b...

Read More >

ELMAH Integration in ASP.NET MVC Application

ELMAH(Error Logging Modules And Handlers)What is ELMAH?ELMAH (Error Logging Modules and Handlers) is...

Read More >

Unit testing in .NET

Unit Testing – ExplainedA process which involves writing code to verify a system at a lower an...

Read More >

THE RAZOR VIEW ENGINE IN MVC

View Engine is responsible for rendering the view into html form to the browser.ASP.NET MVC includes...

Read More >

ViewData and ViewBag in MVC

ASP.NET MVC provides us two options ViewData and ViewBag for passing data from controller to view.Vi...

Read More >

Creating a Simple Form with Validation Using ASP.NET MVC 4 Empty Template

There are multiple Validation attributes available in MVC. Validation attributes comes from System.C...

Read More >

Share

Post a Comment

  • Recent
  • Popular
  • Tag
Tags
Monthly Archive
Subscribe
Name

Contact Us
  • *
  • *