ASP.NET MVC 3 Jonathan Canfield Mavin Lisa Giss Professor Kenytt D. Avery.

21
ASP.NET MVC 3 Jonathan Canfield Mavin Lisa Giss Professor Kenytt D. Avery

Transcript of ASP.NET MVC 3 Jonathan Canfield Mavin Lisa Giss Professor Kenytt D. Avery.

Page 1: ASP.NET MVC 3 Jonathan Canfield Mavin Lisa Giss Professor Kenytt D. Avery.

ASP.NET MVC 3

Jonathan CanfieldMavin Lisa Giss

Professor Kenytt D. Avery

Page 2: ASP.NET MVC 3 Jonathan Canfield Mavin Lisa Giss Professor Kenytt D. Avery.

History of ASP.NET

• Active Server Pages (ASP) released in 1998• Replaced by ASP.NET in 2002– Addressed separation of presentation and content

• ASP.NET MVC framework released in 2009– Integrated with ASP.NET– Framework allowing Model – View – Controller

based development

Page 3: ASP.NET MVC 3 Jonathan Canfield Mavin Lisa Giss Professor Kenytt D. Avery.

What is ASP.NET MVC

• MVC stands for Model-View-Controller which is a framework that is a lightweight, highly testable framework that is integrated with existing ASP.NET features.

• MVC separates an application into three main components for ASP.NET– Model– View– Controller

• This allows software developers to build web apps as a composition of three roles.

Page 4: ASP.NET MVC 3 Jonathan Canfield Mavin Lisa Giss Professor Kenytt D. Avery.
Page 5: ASP.NET MVC 3 Jonathan Canfield Mavin Lisa Giss Professor Kenytt D. Avery.
Page 6: ASP.NET MVC 3 Jonathan Canfield Mavin Lisa Giss Professor Kenytt D. Avery.
Page 7: ASP.NET MVC 3 Jonathan Canfield Mavin Lisa Giss Professor Kenytt D. Avery.

Advantages of MVC

• Makes it easier to manage complexity by dividing app into three roles

• Does not use view state or server-based forms. This gives the developer more control

• Provides better test-driven development • Works well for Web apps that are being

developed by large teams.

Page 8: ASP.NET MVC 3 Jonathan Canfield Mavin Lisa Giss Professor Kenytt D. Avery.

Some Key Features

• Separation of input, business and UI logic.• Components are designed so they can be

easily replaced or customized for a specific need. – For example you could plug in your own view

engine. • Allows you to build web apps

comprehensible and searchable URLs.• Supports existing ASP.NET features.

Page 9: ASP.NET MVC 3 Jonathan Canfield Mavin Lisa Giss Professor Kenytt D. Avery.

Key features continued

• HTML 5 enabled project templates• Expressive views including Razor View Engine• Dependency Injection and Global Action

Filters• JavaScript support

Page 10: ASP.NET MVC 3 Jonathan Canfield Mavin Lisa Giss Professor Kenytt D. Avery.

Building an app

• One nice aspect (for some) is you can use Visual Studio for building apps.

• The Primary language used for ASP.NET MVC is C#

Page 11: ASP.NET MVC 3 Jonathan Canfield Mavin Lisa Giss Professor Kenytt D. Avery.

Controller example

Page 12: ASP.NET MVC 3 Jonathan Canfield Mavin Lisa Giss Professor Kenytt D. Avery.

Views example

Page 13: ASP.NET MVC 3 Jonathan Canfield Mavin Lisa Giss Professor Kenytt D. Avery.

Model Example

Page 14: ASP.NET MVC 3 Jonathan Canfield Mavin Lisa Giss Professor Kenytt D. Avery.

Building a sample app

Page 15: ASP.NET MVC 3 Jonathan Canfield Mavin Lisa Giss Professor Kenytt D. Avery.

• The default template created for a ASP.NET MVC project.

Page 16: ASP.NET MVC 3 Jonathan Canfield Mavin Lisa Giss Professor Kenytt D. Avery.
Page 17: ASP.NET MVC 3 Jonathan Canfield Mavin Lisa Giss Professor Kenytt D. Avery.

Adding a controller to the project

Page 18: ASP.NET MVC 3 Jonathan Canfield Mavin Lisa Giss Professor Kenytt D. Avery.

Adding a method

Page 19: ASP.NET MVC 3 Jonathan Canfield Mavin Lisa Giss Professor Kenytt D. Avery.

Adding a view

Page 20: ASP.NET MVC 3 Jonathan Canfield Mavin Lisa Giss Professor Kenytt D. Avery.

Reasons to Learn ASP.NET MVC

• To unit test

• To gain control and extensibility

• To learn something new

– Google Developer Kevin Pang

Page 21: ASP.NET MVC 3 Jonathan Canfield Mavin Lisa Giss Professor Kenytt D. Avery.

References

http://www.asp.net/mvc/overview/getting-startedhttp://msdn.microsoft.com/en-us/gg618477