asp.net mvc from the ground up

19
ASP.NET MVC From The Ground Up Kevin Griffin

Upload: kevin-griffin

Post on 20-Jan-2015

3.734 views

Category:

Technology


3 download

DESCRIPTION

 

TRANSCRIPT

Page 1: ASP.NET MVC From The Ground Up

ASP.NET MVC From The Ground UpKevin Griffin

Page 2: ASP.NET MVC From The Ground Up

About Me

• .NET Developer• Chesapeake, VA

• Microsoft Client App Dev MVP• Leader of the Hampton Roads .NET Users Group• ASPInsider• INETA Mentor for Virginia

Page 3: ASP.NET MVC From The Ground Up

Before We Begin

• Ask questions• Enjoy the conference, leave if you’re not getting

what you expected

Page 4: ASP.NET MVC From The Ground Up

* From The Ground Up

• Assumptions• You MIGHT be a WebForms Developer• You know nothing about ASP.NET MVC• You’ve tried to sit through MVC talks before and

had trouble• No TDD or IOC mantra today• Just a basic discussion of MVC

Page 5: ASP.NET MVC From The Ground Up

Agenda

• What is MVC?• Components of MVC• Controllers• Views• Models• Ditching the Blue Screen

Page 6: ASP.NET MVC From The Ground Up

What Is MVC?

• Model View Controller• ASP.NET MVC is an alternative way to build web

applications on the ASP.NET platform.• Not a replacement to WebForms

Page 7: ASP.NET MVC From The Ground Up

Let’s get it out of the way

• Web Forms vs. MVC

Page 8: ASP.NET MVC From The Ground Up

MVC Routes

• Convention over Configuration• Default Route• http://domain/Controller/Action/ID• Customizable

Page 9: ASP.NET MVC From The Ground Up

Controller

• BRAIN of the application• Receives input from requests• Performs logic or data requests

Page 10: ASP.NET MVC From The Ground Up

Model

• Representation of the data required to present a view or to send data back to the server.

Page 11: ASP.NET MVC From The Ground Up

View

• The stuff you want to show on the screen.• Bind with a model to provide a data

Page 12: ASP.NET MVC From The Ground Up

DEMOStarting From Scratch

Page 13: ASP.NET MVC From The Ground Up

ActionResults

• How MVC returns data• You specify what you want to return, and MVC

handles the response.

Page 14: ASP.NET MVC From The Ground Up

ActionResults• ViewResult – Represents HTML and markup rendered by a view.• ContentResult – Represents a text result.• EmptyResult – Represents no result.• FileContentResult – Represents a downloadable file (with the binary

content).• FilePathResult – Represents a downloadable file (with a path).• FileStreamResult – Represents a downloadable file (with a file stream).• JavaScriptResult – Represents a JavaScript script.• JsonResult – Represents a JavaScript Object Notation result that can be

used in an AJAX application.• PartialViewResult – Represents HTML and markup rendered by a partial

view.• RedirectResult – Represents a redirection to a new URL.• RedirectToRouteResult – Represents a result that performs a

redirection by using the specified route values dictionary.

Page 15: ASP.NET MVC From The Ground Up

DEMOAdding New Views

Page 16: ASP.NET MVC From The Ground Up

HTML Helpers

• Extension Methods• Helps you render HTML content easily• Replacement for server controls?• Create your own!

Page 17: ASP.NET MVC From The Ground Up

What Is A Model?

• Loosely typed• ViewData dictionary• Strong typed• Bind to a custom object

Page 18: ASP.NET MVC From The Ground Up

DEMOModeling Our View

Page 19: ASP.NET MVC From The Ground Up

Thanks For Attending!

• Questions?!• [email protected]• Twitter: @1kevgriff• http://www.kevgriffin.com