asp.net mvc 5 course module 1 overview

20
ASP.NET MVC 5 COURSE MODULE 1 : OVERVIEW BY SERGEY SELETSKY

Upload: sergey-seletsky

Post on 12-Aug-2015

155 views

Category:

Software


2 download

TRANSCRIPT

ASP.NET MVC 5COURSE

MODULE 1 : OVERVIEW

BY SERGEY SELETSKY

Course overview

Module 1 : Overview

Module 2 : Models

Module 3 : Controllers

Module 4 : Views

Module 5 : Security

Module 6 : Routing

Module 7 : Performance

Module 8 : Testing and Debugging

Module 9 : Web API

Module 10 : Integration

Agenda

Introduction

Architecture

MVC vs Web Forms

Project structure

Configuration

App show case

Best practices

Home work

Introduction

ASP.NET MVC framework is a lightweight, highly testable presentation framework that is integrated with existing ASP.NET features.

First version released at 13 March 2009In April 2009, the ASP.NET MVC source code was released

Introduction

ASP.NET MVC enables a clean separation of concerns and that gives you full control over markup.

TDD-friendlySupport latest web standardsRESTful by default

Architecture

ASP.NET

WebForms

Sites

WebPages

Single Page Apps

MVC Web APISignalR

Services

ASP.NET Overview

ArchitectureWhat does MVC look like?

ControllerControllerRetrieves Model“Does Stuff”

ViewViewVisually representsthe model

Request

Response

Model

MVC vs Web Forms

MVC Web Forms

Stre

ngth

s Full control over HTML Clean HTML Separation of Concerns TDD-friendly Many View Engines RESTful by default Lightweight Simple integration

Designed for RAD Visual Studio Designer Many third-party controls Easy for Win Forms engineers

MVC vs Web Forms

MVC Web Forms

Wea

knes

ses

Not based on server events Complex for Web Forms Dev's Few third-party libraries No View State

UI linked with logic Difficult to test Large page size View State

MVC vs Web Forms

MVC Web Forms

Opp

ortu

nitie

s

Allows to use TDD Reusable Better integrability

RAD

MVC vs Web Forms

MVC Web Forms

Thre

ats Difficult to learn

Slow in developing Difficult to integrate Difficult for UI Developers

Project structure

By default, MVC projects include the following folders:

•App_Data, store folder for data. This folder has the same role in ASP.NET Web Forms.

•Content, which is the recommended location for static files.

•Controllers, which is the recommended location for controllers.

•Models, which is provided for classes that represent the app.

•Scripts, folder for script files.

•Views, which is the recommended location for views.

Project structure

Creating first project demo

Configuration

Routing configuration

public class RouteConfig { public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

routes.MapRoute( name: "Default", url: "{controller}/{action}/{id}", defaults: new {

controller = "Home", action = "Index", id = UrlParameter.Optional }

); } }

Configuration

Bundling and Minifying configuration

public static void RegisterBundles(BundleCollection bundles) { bundles.Add(new ScriptBundle("~/bundles/bootstrap") .Include("~/Scripts/bootstrap.js", "~/Scripts/respond.js"));

bundles.Add(new StyleBundle("~/Content/css") .Include("~/Content/bootstrap.css", "~/Content/site.css")); }@Scripts.Render("~/bundles/bootstrap")

@Styles.Render("~/Content/css")

Real app showcase

Commercial open source app demo

Best practices

Keep Controllers Thin

Home work

Create your own solution

1. Create ASP.NET MVC 5 Project for future sessions2. Create book model with few properties3. Create view for book model4. Create books controller5. Use your book model in books controller6. Implement creating and editing for books

References

Professional ASP.NET MVC 5By Jon Galloway

Pro ASP.NET MVC 5By Adam Freeman

Programming Microsoft ASP.NET MVC, Third EditionBy Dino Esposito

THANK YOU

20

Sergey Seletsky

[email protected]://www.linkedin.com/in/sergeyseletsky