ASP.NET MVC 4 Asp.net
MVC ConsultantBusiness & Decision
HRICHIMohamed
What Is MVC ?
• Model-View-Controller• A design Pattern (Methodology)• Invented by Smalltalk programmer
(Trygve Reenskaug 1979).• Separation of Concerns / Single
Responsibility Principle• More easily testable
What Is MVC ?
• ModelDataBusiness rules
• View User interfaceThe representation of Model
• ControllerApplication’s Brain (Handle user requests, bind
Datareturn views)
Model View Controller Pattern
Asp.net MVC
• Separation of application tasks (No code Behind)
• An extensible and pluggable framework• Friendly URLs (Routing)• More Control Over HTML (No server side
Controls)• Supports existing ASP.NET features
(Authentication, Membership, roles, output caching,…)
• Easily Testable
Demo: Asp.net MVC Hello World
Asp.net MVC 4 Features
• Bundling/Minification• Mobile Template• Web APIs• Asynchronous • Real-time communication
Bundling and Minification
Improve JavaScript and CSS files loading• Minimize the Number of requests (Bundle in one File)• Reduce the size of files (remove spaces, enters and
comments)
Fully customizable and extensible
Without Bundling and Minification
With Bundling and Minification
Demo: Bundling and Minification
Mobile Template
Adaptive RenderingUse of CSS Media Queries within default project templates
Display ModesSelectively adapt views based on devices
Mobile Optimized TemplatesjQuery Mobile
Demo: Mobile Templete
Web APIsSimple way to expose data and services (RESTful web service)
Reach a broad range of clients (Browsers, Mobile, desktop)
Multiple ways to host and expose Web APIs
Same programming model
Maximum flexibility (Json, XML, …)
Demo: Web Api
Asynchronous
Asynchronous action methods for long-running
Calling Web Services Asynchronously
More efficient use of threads and server resources
Asynchronous
public class Products : Controller {
public async Task<ActionResult> IndexAsync() {
WebClient web = new WebClient();
string result = await web.DownloadStringAsync("www.bing.com/"); return View(); }}
Real-time communication (SignalR)• Real-time web functionality (Chat, Games)• Push content to the connected clients• call JavaScript functions in your clients' browsers
from server-side .NET code
Demo: SignalR
Questions