What is MVC?
MVC is a framework
pattern that splits an application’s implementation logic into
three component roles:
models, views, and controllers.
·
Model: The business entity on which the
overall application operates. Many applications use a persistent storage
mechanism (such as a database) to store data. MVC does not specifically mention
the data access layer because it is understood to be encapsulated by the Model.
·
View: The user interface that renders the
Model into a form of interaction.
·
Controller: Handles a request from a View and
updates the Model that results in a change of the Model's state.
To implement MVC in
.NET we need mainly three classes (View, Controller and the Model).
Explain MVC
Architecture?
The architecture is
self explanatory. The browser (as usual) sends a request to IIS, IIS searches
for the route defined in MVC application and passes the request to the
controller as per route, the controller communicates with the model and passes
the populated model (entity) to View (front end), Views are populated with
model properties, and are rendered on the browser, passing the response to
browser through IIS via controllers which invoked the particular View.
What are the new features of MVC2?
ASP.NET MVC 2 was
released in March 2010. Its main features are:
1.
Introduction of UI
helpers with automatic scaffolding with customizable templates.
2.
Attribute-based model validation on both
client and server.
3.
Strongly typed
HTML helpers.
4.
Improved Visual
Studio tooling
5.
There were also lots
of API enhancements and “pro” features, based on feedback from developers
building a variety of applications on ASP.NET MVC 1, such as:
·
Support for partitioning large
applications into areas.
·
Asynchronous controllers support.
·
Support for rendering subsections of a
page/site using Html.RenderAction.
·
Lots of new helper functions, utilities,
and API enhancements
What are the new features of MVC3?
ASP.NET MVC 3 shipped
just 10 months after MVC 2 in Jan 2011.Some of the top features in MVC 3
included:
·
The Razor view
engine.
·
Support for .NET
4 Data Annotations.
·
Improved model
validation
·
Greater control
and flexibility with support for dependency resolution and global action
filters.
·
Better
JavaScript support with unobtrusive JavaScript, jQuery Validation, and JSON
binding.
·
Use of NuGet to
deliver software and manage dependencies throughout the platform.
What are the new
features of MVC4?
Following are the top
features of MVC4:
·
ASP.NET Web API.
·
Enhancements to
default project templates.
·
Mobile project
template using jQuery Mobile.
·
Display Modes.
·
Task support for
Asynchronous Controllers.
·
Bundling and
minification.
Explain “page
lifecycle” of an ASP.NET MVC?
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
Advantages of MVC
Framework?
1.
Provides a clean
separation of concerns between UI (Presentation layer), model (Transfer
objects/Domain Objects/Entities) and Business Logic (Controller).
2.
Easy to UNIT
Test.
3.
Improved
reusability of views/model. One can have multiple views which can point tosame
model and vice versa.
4.
Improved
structuring of the code.
What do you mean by
Separation of Concerns?
As per Wikipedia 'the
process of breaking a computer program into distinct features that overlap in
functionality as little as possible'. MVC design pattern aims to separate
content from presentation and data-processing from content.
Where do we see
Separation of Concerns in MVC?
Between the
data-processing (Model) and the rest of the application.
When we talk about
Views and Controllers, their ownership itself explains separation. The views
are just the presentation form of an application, it does not have to know
specifically about the requests coming from controller. The Model is
independent of View and Controllers, it only holds business entities that can
be passed to any View by the controller as required for exposing them to the
end user. The controller is independent of Views and Models, its sole purpose
is to handle requests and pass it on as per the routes defined and as per the
need of rendering views. Thus our business entities (model), business logic
(controllers) and presentation logic (views) lie in logical/physical layers
independent of each other.
What is Razor View
Engine?
Razor is the first
major update to render HTML in MVC3. Razor was designed specifically as a view
engine syntax. It has one main focus: code-focused templating
for HTML generation. Here’s how that same markup would be generated using
Razor:
@model MvcMusicStore.Models.Genre
@{ViewBag.Title = "Browse
Albums";}
<div class="genre">
<h3><em>@Model.Name</em> Albums</h3>
<ul id="album-list">
@foreach (var album in Model.Albums)
{
<li>
<a href="@Url.Action("Details",
new { id = album.AlbumId })">
<img alt="@album.Title" src="@album.AlbumArtUrl" />
<span>@album.Title</span>
</a>
</li>
}
</ul>
</div>
The Razor syntax is
easier to type, and easier to read. Razor doesn’t have the XML-like heavy
syntax.
of the Web Forms view
engine.
What is Unobtrusive
JavaScript?
Unobtrusive JavaScript
is a general term that conveys a general philosophy, similar to the term
REST (Representational
State Transfer). The high-level description is that unobtrusive JavaScript
doesn’t intermix JavaScript code in your page markup. For example, rather than
hooking in via event attributes like onclick and onsubmit, the unobtrusive
JavaScript attaches to elements by their ID or class, often based on the
presence of other attributes (such as HTML5 data- attributes).
It’s got semantic
meaning, and all of it — the tag structure, element attributes, and so on —
should have a precise meaning. Strewing JavaScript gunk across the page to
facilitate interaction (I’m looking at you, __doPostBack!) harms the content of
the document.


No comments:
Post a Comment