Introduction to ASP.NET MVC

Slides:



Advertisements
Similar presentations
Svetlin Nakov Director Training and Consulting Activities National Academy for Software Development (NASD) ASP.NET 3.5 New Features.
Advertisements

.NET 3.5 SP1 New features Enhancements Visual Studio 2008 SP1 New features Enhancements Additional features/enhancements.
Introduction to ASP.NET MVC
INTRODUCTION TO ASP.NET MVC AND EXAMPLE WALKTHROUGH RAJAT ARYA EFECS - OIM DAWG – 4/21/2009 ASP.NET MVC.
{ Model View Controller ASP.NET By Scott Crooks & Maggie Wettergreen.
Fabian Vilers Hands on ASP.NET MVC.
Kashif Jalal CA-240 (072) Web Development Using ASP.NET CA – 240 Kashif Jalal Welcome to week – 2 of…
Tutorial -01. Objective In this session we will discuss about : 1.What is MVC? 2.Why MVC? 3.Advantages of MVC over ASP.NET 4.ASP.NET development models.
User Group 2015 Version 5 Features & Infrastructure Enhancements.
Christopher M. Pascucci Basic Structural Concepts of.NET Browser – Server Interaction.
UNIT-V The MVC architecture and Struts Framework.
Kay Herzam Herzam IT Consulting What‘s new in ASP.NET MS TechTalk.
Creating and Running Your First C# Program Telerik Software Academy Telerik School Academy.
Windows.Net Programming Series Preview. Course Schedule CourseDate Microsoft.Net Fundamentals 01/13/2014 Microsoft Windows/Web Fundamentals 01/20/2014.
Ori Calvo, 2010 Hi-Tech College
Ori Calvo, 2010 “If people want to have maximum reach across *all* devices then HTML will provide the broadest reach” Scott Guthrie,
Introduction to the Enterprise Library. Sounds familiar? Writing a component to encapsulate data access Building a component that allows you to log errors.
Architecture Of ASP.NET. What is ASP?  Server-side scripting technology.  Files containing HTML and scripting code.  Access via HTTP requests.  Scripting.
Chapter 1: Introduction to Web
ASP.NET and Model View Control Jesper Tørresø ITNET2 F08.
Building Web Sites with ASP.NET MVC Framework Noam King CTO Sela College
ASP.NET Web Application and Development Digital Media Department Unit Credit Value : 4 Essential Learning time : 120 hours Digital.
Introduction to ASP.NET MVC Information for this presentation was taken from Pluralsight Building Applications with ASP.NET MVC 4.
The Web Architecture and ASP.NET. Slide 2 Review of the Web (1) It began with HTTP and HTML, which delivers static Web pages to browsers which would render.
Lap Around Visual Studio 2008 &.NET 3.5 Enhancements.
Kingdom of Saudi Arabia Ministry of Higher Education Al-Imam Muhammad Ibn Saud Islamic University College of Computer and Information Sciences Chapter.
Jonathan Canfield Mavin Lisa Giss Professor Kenytt D. Avery
Getting Started with ASP.NET MVC BRIJ BHUSHAN MISHRA.
ASP.NET MVC Introduction MVC, Models, Views, Controllers, ASP.NET SoftUni Team Technical Trainers Software University
Getting started with ASP.NET MVC Dhananjay
ASP.NET MVC Telerik Academy
Text INTRODUCTION TO ASP.NET. InterComm Campaign Guidelines CONFIDENTIAL Simply Server side language Simplified page development model Modular, well-factored,
Virtual techdays INDIA │ 9-11 February 2011 SESSION TITLE Kamala Rajan S │ Technical Manager, Marlabs.
Introduction to ASP.NET development. Background ASP released in 1996 ASP supported for a minimum 10 years from Windows 8 release ASP.Net 1.0 released.
ASP.NET WEB Applications. ASP.NET  Web application framework developed by Microsoft  Build dynamic data driven web applications and web services  Subset.
The New Face of ASP.NET ASP.NET MVC, Razor, and jQuery Ido Flatow | Senior Architect | Sela | This session is.
ASP.NET Core* 1.0 The Future of Web Apps Shahed Chowdhuri
//liveVirtualacademy2011/ What’s New for ASP.NET 4.5 and Web Development in Visual Studio 11 Developer Preview Γιώργος Καπνιάς MVP, MCT, MCDP, MCDBA, MCTS,
INTRODUCTION TO MVC BY SUHA MNEIMNEH. WHAT’S THE AGENDA What is MVC? MVC components MVC vs web forms vs ASP.NET vocabulary When to create MVC application.
© Copyright SELA software & Education Labs Ltd Baruch Hirsch St.Bnei Brak Israel
Introduction to ASP.NET MVC [Name] [ Address] [Blog URL]
Introduction to MVC Slavomír Moroz. Revision from Previous Lesson o ASP.NET WebForms applications Abstract away HTTP (similar to desktop app development)
National College of Science & Information Technology.
Chapter 1 Getting Started with ASP.NET Objectives Why ASP? To get familiar with our IDE (Integrated Development Environment ), Visual Studio. Understand.
Web Technology Solutions
Kendo UI ASP.NET MVC Wrappers
Introducing the Microsoft® .NET Framework
Build and Learn ASP.NET Workshop.
Web Programming Language
ASP.NET AJAX – Basics Svetlin Nakov Telerik Corporation
Using ASP.NET Master Pages
TechEd /1/2018 7:56 AM © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks.
JavaScript Applications: Course Introduction
MVC Architecture, Symfony Framework for PHP Web Apps
Kendo UI ASP.NET MVC Wrappers
ASP.NET MVC Introduction
Haritha Dasari Josue Balandrano Coronel -
CO6025 Advanced Programming
PHP / MySQL Introduction
Introduction to ASP.NET MVC
WEB API.
Web Development Using ASP .NET
Lecture 1: Multi-tier Architecture Overview
ASP.NET Module Subtitle.
Serpil TOK, Zeki BAYRAM. Eastern MediterraneanUniversity Famagusta
ASP.NET MVC Web Development
An Introduction to JavaScript
ASP.NET MVC Imran Rashid CTO at ManiWeber Technologies.
Introduction to ASP.NET Parts 1 & 2
Web Application Development Using PHP
Presentation transcript:

Introduction to ASP.NET MVC Telerik School Academy http://academy.telerik.com

Table of Contents The HTTP Protocol The MVC Pattern ASP.NET MVC Model, View, Controller The MVC Pattern for Web and Examples ASP.NET MVC Comparison with ASP.NET ASP.NET MVC Advantages Creating ASP.NET MVC Project NuGet Package Management Server Information with Glimpse

HTTP The HTTP Protocol How HTTP Works? * 07/16/96 (c) 2007 National Academy for Software Development - http://academy.devbg.org. All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.*

HTTP Hyper Text Transfer Protocol (HTTP) Important properties of HTTP Client-server protocol for transferring Web resources (HTML files, images, styles, etc.) Important properties of HTTP Request-response model Text-based format Relies on a unique resource URLs Provides resource metadata (e.g. encoding) Stateless (cookies can overcome this)

HTTP: Request-Response Protocol Client program Running on end host E.g. Web browser Requests a resource Server program Running at the server E.g. Web server Provides resources GET /index.html HTTP/1.0 HTTP/1.0 200 OK "Welcome to our Web site!" 5

HTTP Request Message Request message sent by a client consists of Request line – request method (GET, POST, HEAD, ...), resource URI, and protocol version Request headers – additional parameters Body – optional data E.g. posted form data, files, etc. <request method> <resource> HTTP/<version> <headers> <empty line> <body>

HTTP Response Message Response message sent by the server Status line – protocol version, status code, status phrase Response headers – provide meta data Body – the contents of the response (the requested resource) HTTP/<version> <status code> <status text> <headers> <CRLF> <response body – the requested resource>

HTTP Response Codes HTTP response code classes 1xx: informational (e.g., “100 Continue”) 2xx: success (e.g., “200 OK”) 3xx: redirection (e.g., “304 Not Modified”, "302 Found") 4xx: client error (e.g., “404 Not Found”) 5xx: server error (e.g., “503 Service Unavailable”) "302 Found" is used for redirecting the Web browser to another URL

HTTP Cookies Cookie Cookies are small pieces of data stored by the client on behalf of the server Included in all future HTTP requests to the server Request Response Set-Cookie: XYZ Next request Cookie: XYZ

The MVC Pattern

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

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

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

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"

MVC Steps Incoming request routed to Controller For web: HTTP request Controller processes request and creates presentation Model Controller also selects appropriate result (view) Model is passed to View View transforms Model into appropriate output format (HTML) Response is rendered (HTTP Response)

Front controller (dispatcher) The MVC Pattern for Web HTTP Request Front controller (dispatcher) /Some/Page/ Delegate request User Controller HTTP Response CRUD model Select view & pass data View (render UI) Model (data) Use model data

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)

ASP.NET MVC

ASP.NET Core ASP.NET WebForms ASP.NET MVC ASP.NET Presentation Runtime Caching .NET Handlers Routes Pages Controls Globalization Profile Master Pages Membership Roles Etc... ASP.NET Runtime

ASP.NET Web Forms Stable and mature, supported by heaps of third party controls and tools Event driven web development Postbacks Viewstate Less control over the HTML Hard to test Rapid development

ASP.NET History Classic ASP introduced in late 1990's ASP.NET 1.0 – 2002 (Web Forms) ASP.NET 3.5 – 2008 (First version of MVC) Two more versions in next two years ASP.NET 4 – 2010 (VS 2010, MVC 2.0, Razor) ASP.NET 4.5 (First version of Web API, VS 2012) February 2013 – SignalR Autumn 2013 – VS 2013, One ASP.NET, MVC 5 ASP.NET vNext – 2014, Roslyn, Platform ind.

One ASP.NET Web Forms ASP.NET MVC Web Pages Web API SignalR Component-based ASP.NET MVC Web Pages Lightweight framework for dynamic content Web API Framework for building RESTful Web services SignalR Real-time client-server communication

ASP.NET MVC Runs on top of ASP.NET Embrace the web Uses MVC pattern Not a replacement for WebForms Leverage the benefits of ASP.NET Embrace the web User/SEO friendly URLs, HTML 5, SPA Adopt REST concepts Uses MVC pattern Conventions and Guidance Separation of concerns

ASP.NET MVC (2) Tight control over markup Testable Loosely coupled and extensible Convention over configuration Razor view engine One of the greatest view engines With intellisense, integrated in Visual Studio Reuse of current skills (C#, EF, LINQ, JS, etc.) Application-based (not scripts like PHP)

The ASP.NET MVC History ASP.NET MVC 1.0 ASP.NET MVC 2.0 (Areas, Async) In February 2007, Scott Guthrie ("ScottGu") of Microsoft sketched out the core of ASP.NET MVC Released on 13 March 2009 ASP.NET MVC 2.0 (Areas, Async) Released just one year later, on 10 March 2010 ASP.NET MVC 3.0 (Razor) – 13 January 2011 ASP.NET MVC 4.0 (Web API) – 15 August 2012 ASP.NET MVC 5.0 (Identity) – 17 October 2013 ASP.NET MVC 6.0 – soon enough (seminar)

Separation of Concerns Each component has one responsibility SRP – Single Responsibility Principle DRY – Don’t Repeat Yourself More easily testable TDD – Test-driven development Helps with concurrent development Performing tasks concurrently One developer works on views Another works on controllers

Extensible Replace any component of the system Interface-based architecture Almost anything can be replaced or extended Model binders (request data to CLR objects) Action/result filters (e.g. OnActionExecuting) Custom action result types View engine (Razor, WebForms, NHaml, Spark) View helpers (HTML, AJAX, URL, etc.) Custom data providers (ADO.NET), etc.

Clean URLs REST-like Friendlier to humans Friendlier to web crawlers /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)

Community-based ASP.NET MVC, Web API, and Web Pages source code is available in CodePlex http://aspnetwebstack.codeplex.com/ You can vote for new features in ASP.NET UserVoice site http://aspnet.uservoice.com/forums/41199- general-asp-net vNext is on GitHub https://github.com/aspnet

MVC Pattern in ASP.NET MVC HTTP Request Web server ASP.NET MVC Routing engine /Users/Ivo/ Select controller and invoke action (method) User Controller (C# class) HTTP Response (HTML, File, JSON, …) CRUD model Select view & pass data (model) View engine (Razor) Model (POCO) Use model data

Creating ASP.NET MVC Project

The Tools Tools that we need: IDE: Visual Studio 2013 (2012 is also OK) Framework: .NET Framework 4.5 Web server: IIS 8.5 (Express) Data: Microsoft SQL Sever (Express or LocalDB) Visual Studio installer will install everything we need http://www.microsoft.com/visualstudio/eng/20 13-downloads

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

Visual Studio 2012: New Project

VS 2012: Default Layout

Visual Studio 2013: New Project

VS 2013: Default Layout

Internet App Project Files Static files (CSS, Images, etc.) All controllers and actions JavaScript files (jQuery, Modernizr, knockout, etc.) View templates _Layout.cshtml – master page (main template) Application_Start() – The entry point of the application Web.config – Configuration file

Demo: Internet application Making changes and debugging

NuGet Package Management

NuGet package management Free, open source package management Makes it easy to install and update open source libraries and tools Part of Visual Studio 2012/2013 Configurable package sources Simple as adding a reference GUI-based package installer Package manager console

Nightly Builds Nightly builds of ASP.NET MVC are available via a private NuGet feed In your Package Manager settings add the following package source: http://www.myget.org/F/aspnetwebstacknightly/

Install and update packages as easy as adding a reference Demo: NuGet Install and update packages as easy as adding a reference

Server Information with Glimpse The open source diagnostics platform of the web

Server Info with Glimpse Glimpse shows execution timings, server configuration, request data and more Showed inside browser (like FireBug) With no changes to the application code Supports ASP.NET MVC, WebForms and EF

Install Glimpse Install NuGet packages: Run the project Configure it: Glimpse.Mvc5 Glimpse.EF6 Run the project Configure it: http://localhost:port/Glimpse.axd

Tracing with Glimpse The Trace tab shows any messages traced to System.Diagnostics.Trace or System.Diagnostics.Debug during the lifetime of the HTTP request. Trace.TraceInformation("Info example"); Trace.TraceWarning("Warning example"); Debug.WriteLine("Debug example");

Demo: Glimpse

Summary HTTP is a client-server protocol for transferring web resources via Internet Model–view–controller (MVC) is a software architecture pattern ASP.NET MVC is a great platform for developing Internet applications Visual Studio is the main development tool for creating ASP.NET MVC applications Almost everything in ASP.NET MVC is a package Glimpse is a tool that helps with debugging

Introduction to ASP.NET MVC http://academy.telerik.com

Free Trainings @ Telerik Academy “C# Programming @ Telerik Academy csharpfundamentals.telerik.com Telerik Software Academy academy.telerik.com Telerik Academy @ Facebook facebook.com/TelerikAcademy Telerik Software Academy Forums forums.academy.telerik.com