0% found this document useful (0 votes)
61 views29 pages

Building Web Sites With: Israr Ali

1. The document discusses ASP.NET MVC, a web application framework that follows the model-view-controller pattern. 2. It separates an application into three main components: the model, the view, and the controller. The model manages the data logic, the view displays the UI, and the controller handles requests and responses between the model and view. 3. The document provides an overview of ASP.NET MVC, covering its architecture, routing, controllers, views, and models. It emphasizes clean separation of concerns, testability, and building applications in a REST-like manner with friendly URLs.

Uploaded by

zaffar khan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
61 views29 pages

Building Web Sites With: Israr Ali

1. The document discusses ASP.NET MVC, a web application framework that follows the model-view-controller pattern. 2. It separates an application into three main components: the model, the view, and the controller. The model manages the data logic, the view displays the UI, and the controller handles requests and responses between the model and view. 3. The document provides an overview of ASP.NET MVC, covering its architecture, routing, controllers, views, and models. It emphasizes clean separation of concerns, testability, and building applications in a REST-like manner with friendly URLs.

Uploaded by

zaffar khan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 29

Building Web Sites with

ASP.NET MVC Framework


ISRAR ALI
Agenda
• First Steps
• Architecture
• Forms & Action Filters
• Using Ajax & Security
• Extending MVC
• Q&A
• Summary
Why should I care?
• Build applications faster
• Scale easily
• Test better
What is ASP.NET MVC?

• A new Web Application Project type


• Simply an option
• Not a replacement for WebForms
• Builds on top ASP.NET
• Manual vs Automatic Transmission
What is MVC?

Model

View Controller
Separation Of Concerns
• Each component has one responsibility
• SRP : Single Responsibility Principle

• DRY : Don’t Repeat Yourself

• More easily testable

• Helps with concurrent development


The MVC Pattern
• Model–view–controller (MVC) is a software architecture pattern
• Originally formulated in the late 1970s by Trygve Reenskaug as part of
the Smalltalk
• Code reusability and separation of concerns
• Originally developed for
desktop, then adapted
for internet applications

7
Model
• Set of classes that describes the data we are
working with as well as the business
• Rules for how the data can be changed and
manipulated
• May contain data validation rules
• Often encapsulate data stored in a database as
well as code used to manipulate the data
• Most likely a Data Access Layer of some kind
• Apart from giving the data objects, it doesn't have
significance in the framework
8
View
• Defines how the application’s user interface (UI) will be displayed
• May support master views (layouts) and sub-views (partial views or
controls)
• Web: Template to dynamically generate HTML

9
Controller
• The core MVC component
• Process the requests with the help of views and models
• A set of classes that handles
• Communication from the user
• Overall application flow
• Application-specific logic
• Every controller has one or more "Actions"

10
MVC Frameworks
• CakePHP (PHP)
• CodeIgniter (PHP)
• Spring (Java)
• Perl: Catalyst, Dancer
• Python: Django, Flask, Grok
• Ruby: Ruby on Rails, Camping, Nitro, Sinatra
• JavaScript: AngularJS, JavaScriptMVC, Spine
• ASP.NET MVC (.NET Framework)

11
ASP.NET Core

ASP.NET ASP.NET Presentation


WebForms MVC

ASP.NET
Caching .NET Globalization

Pages Controls Master Pages Runtime


Profile Roles Membership

Routes Handlers Etc...

12
Clean URLs
• REST-like
• /products/update
• /blog/posts/2013/01/28/mvc-is-cool
• Friendlier to humans
• /product.aspx?catId=123 or post.php?id=123
• Becomes /products/chocolate/
• Friendlier to web crawlers
• Search engine optimization (SEO)

13
ASP.NET MVC Request

14
The Technologies
• Technologies that ASP.NET MVC uses
• C# (OOP, Unit Testing, async, etc.)
• HTML(5) and CSS
• JavaScript (jQuery, KendoUI, etc.)
• AJAX, Single-page apps
• Databases (MS SQL)
• ORM (Entity Framework and LINQ)
• Web and HTTP

15
Demo
MVC First Steps
What MVC is not ?

• Not the new Web Forms


• Not replacing Web Forms, but Adds to it
• It can not use Web Controls
• Not a whole new engine but sits on ASP.NET engine
• Not the best solution for REST
What MVC is?

• Maintain Clean Separation of Concerns


• Extensible and Pluggable
• Enable clean URLs and HTML
• Great integration within ASP.NET
• Tooling Support
MVC Flow

Controller
Request

Step 1
Incoming request directed to Controller
MVC Flow

Controller
Model

Step 2
Controller processes request and forms a data Model
MVC Flow

Controller

View
Step 3
Model is passed to View
MVC Flow

Controller

View

Step 4
View transforms Model into appropriate output format
MVC Flow

Controller

View
Response
Step 5
Response is rendered
Request Flow – in more detail

Request

HTTP Http
Routing Controller Response
Handler

Route View
Route View
Handler Engine
Routing Engine
• URLs -> application -> Controller Action
• Construct outgoing URLs
• Constructed URLs can be used to call back to
Controllers/Actions
Demo
Routing
Summary
• Not a replacement for WebForms
• All about alternatives
• Fundamental
• Part of the System.Web namespace
• Same team that builds WebForms
Additional Resources
• Official sites
• Central landing site: http://asp.net/mvc
• Forums: http://forums.asp.net/1146.aspx
• Source available
• Source drop: http://codeplex.com/aspnet
• Blogs
• http://blogs.microsoft.co.il/blogs/noam
• http://weblogs.asp.net/scottgu
• http://hanselman.com/
• http://haacked.com/

You might also like