Introduction to ASP.NET MVC Blogging Engine in 60 minutes - PowerPoint PPT Presentation

1 / 26
About This Presentation
Title:

Introduction to ASP.NET MVC Blogging Engine in 60 minutes

Description:

Introduction to ASP.NET MVC Blogging Engine in 60 minutes. Adnan Masood. www.AdnanMasood.com. www.CodePlex.com/YABE – PowerPoint PPT presentation

Number of Views:104
Avg rating:3.0/5.0
Slides: 27
Provided by: adnanmaso
Category:

less

Transcript and Presenter's Notes

Title: Introduction to ASP.NET MVC Blogging Engine in 60 minutes


1
Introduction to ASP.NET MVC Blogging Engine in 60
minutes
  • Adnan Masood
  • www.AdnanMasood.com
  • www.CodePlex.com/YABE

2
About Meaka. Shameless Self Promotion
  • Sr. Software Engineer / Tech Lead for Green Dot
    Corp. (Financial Institution)
  • Design and Develop Connected Systems
  • Involved with SoCal Dev community, co-founded San
    Gabriel Valley .NET Developers Group. Published
    author and speaker.
  • MS. Computer Science, MCPD (Enterprise
    Developer), MCT, MCSD.NET
  • Doctoral Student - Areas of Interest Machine
    learning, Bayesian Inference, Data Mining,
    Collaborative Filtering, Recommender Systems.
  • Contact at adnanmasood_at_acm.org
  • Read my Blog at www.AdnanMasood.com
  • Doing a session in IASA 2008 in San Francisco on
    Aspect Oriented Programming for details visit
    http//www.iasaconnections.com

3
YABEYet another blogging engine
  • Team
  • Adnan Masood
  • Jeff Bergman
  • Sean Xiao
  • www.CodePlex.com/YABE
  • Uses Linq to SQL for data access
  • Syndication Libraries for the RSS/Atom Feeds
  • Experiment in learning MVC

4
Latest Developments in the MVC world
  • Scott Guthrie, adaptation from RoR
  • How does this relate to Visual Studio 2008/.NET
    3.5 SP1 Beta?
  • It doesn't. For now ASP.NET MVC is an out-of-band
    Web downloadable thing. It's bin deployable
    (meaning you don't HAVE to put them in the GAC)
    and you don't even need to tell your hosting/ISP.
    They are what they are - three DLLs in a folder.
    Bam.
  • MVC Preview 3 will not be affected by having SP1
    installed. Preview 3 will include newer privately
    versioned bin deployable builds of the Routing
    and Abstractions DLLs. That way these assemblies
    will not be affected by the versions in the GAC
    installed by SP1, because they will have
    different version numbers.

5
MVC vs. Classic ASP.NET
6
Ok, so what is this MVC thingy?
  • It is an ASP.NET framework that performs data
    exchange by using a REST model versus the
    postback model of classic ASP.NET. Each page is
    split into two distinct components -controller
    and view - that operate over the same model of
    data. This is opposed to the classic code-behind
    model where no barrier is set that forces you to
    think in terms of separation of concerns and
    controllers and views. However, by keeping the
    code-behind class as thin as possible, and
    designing the business layer appropriately, a
    good developer could achieve separation of
    concerns even without adopting MVC and its
    overhead. MVC, however, is a model superior to a
    properly-done code-behind for its inherent
    support for test-driven development.

7
Model View Controller Pattern
8
More Concrete Model View Controller Pattern
9
Why use ASP.NET MVC?
  • It enables clean separation of concerns,
    testability, and TDD by default.  All core
    contracts within the MVC framework are interface
    based and easily mockable (it includes interface
    based IHttpRequest/IHttpResponse intrinsics). 
    You can unit test the application without having
    to run the Controllers within an ASP.NET process
    (making unit testing fast).  You can use any unit
    testing framework you want to-do this testing
    (including NUnit, MBUnit, MS Test, etc).
  • It is highly extensible and pluggable. 
    Everything in the MVC framework is designed so
    that it can be easily replaced/customized (for
    example you can optionally plug-in your own view
    engine, routing policy, parameter serialization,
    etc).  It also supports using existing dependency
    injection and IOC container models (Windsor,
    Spring.Net, NHibernate, etc).
  • It includes a very powerful URL mapping component
    that enables you to build applications with clean
    URLs.  URLs do not need to have extensions within
    them, and are designed to easily support SEO and
    REST-friendly naming patterns.  For example, I
    could easily map the /products/edit/4 URL to the
    "Edit" action of the ProductsController class in
    my project above, or map the /Blogs/scottgu/10-10-
    2007/SomeTopic/ URL to a "DisplayPost" action of
    a BlogEngineController class.
  • The MVC framework supports using the existing
    ASP.NET .ASPX, .ASCX, and .Master markup files as
    "view templates" (meaning you can easily use
    existing ASP.NET features like nested master
    pages, lt gt snippets, declarative server
    controls, templates, data-binding, localization,
    etc).  It does not, however, use the existing
    post-back model for interactions back to the
    server.  Instead, you'll route all end-user
    interactions to a Controller class instead -
    which helps ensure clean separation of concerns
    and testability (it also means no viewstate or
    page lifecycle with MVC based views).
  • The ASP.NET MVC framework fully supports existing
    ASP.NET features like forms/windows
    authentication, URL authorization,
    membership/roles, output and data caching,
    session/profile state management, health
    monitoring, configuration system, the provider
    architecture, etc.

10
Why MVC is so different?
  • REST is an architectural pattern that defines how
    network resources should be defined and addressed
    in order to gain shorter response times, clear
    separation of concerns between the front-end and
    back-end of a networked system. REST is based on
    three following principles
  • An application expresses its state and implements
    its functionality by acting on logical resources
  • Each resource is addressed using a specific URL
    syntax
  • All addressable resources feature a contracted
    set of operations

11
The answer to Urls Life, 42.
  • In the MVC Framework, a URL is seen as the mean
    to address a logical server resource, but not
    necessarily an ASPX file to parse. So the URLs
    employed by the pages of an MVC Framework
    application have a custom format that the
    application itself mandates. In the end, the MVC
    Framework employs a centralized HTTP handler that
    recognizes an application-specific syntax for
    links. In addition, each addressable resource
    exposes a well-known set of operations and a
    uniform interface for executing operations.

12
What? No more postbacks!
  • The MVC Framework doesn't support classic
    postbacks and viewstate and doesn't consider any
    URL as the endpoint to a physical server file to
    parse and compile to a class. In ASP.NET, you
    have a 11 correspondence between a URL and a
    resource.

13
Why MVC? (links)
  • The REST-like Aspect of MVC Framework
  • ASP.NET MVC Framework An early look
  • RSS Feed with the new ASP.NET MVC Framework
  • MVC, REST, and the Alternative ASP.NET Framework
  • ASP.NET MVC framework - ready or not

14
Why MVC?
  • Very Clean separation of Concerns
  • Unit Testing
  • Model that leads you down a maintainable path
    (prevent crappy code)
  • Clean Urls and Html

15
Front Controller
  • Classic asp.net framework is Page Controller
  • Map Urls to classes/controllers instead of Pages

16
Unit Testing
  • Mock Objects to simulate responses.
  • Dont have to go through a page or view
  • Red/Green Testing

17
Unit Testing
  • Create instance of controller
  • controller.ViewEngine new TestViewEngine()
  • Uses Mock Objects

18
Features
  • Routing
  • Controller
  • View
  • Dependency Injection
  • Pluggable
  • Interfaces for all core contracts

19
Url
  • Url no longer points to the view/aspx page
  • A Url maps to a controller class
  • Allows more flexibility to map Urls
  • Url routing engine, Route table
  • Routes are tokenized strings
  • Can use RegEx

20
Route Examples
  • ltControllergt/ltActiongt/ltParamgt
  • http//domain/Home/CustomerDetail/45
  • Html.Link for creating outbound urls
  • Html.Link(ltFriendly Namegt, ltActiongt, ltControllergt)

21
Controller
  • IController
  • Execute(IHttpContext ctx, RouteData routeData)
  • class MyController Controller
  • ControllerAction attribute

22
View
  • Similar to existing page
  • No postback or view state
  • Not all page events will fire
  • Editing forms will be more work
  • Separate page for viewing, editing, and updating
  • Ajax will use UserControls as update panels but
  • request still goes through the control

23
Views
  • View probably shouldnt directly access data
    sources or services.
  • Use the ViewData which stores the model the view
    is rendering
  • ViewPageltTgt, ViewPage

24
Future of the ASP.NET MVC
  • MVC for the Enterprise
  • Classic Asp.Net for quicker implementations

25
References
  • Download the Latest MVC Preview
    3http//www.microsoft.com/downloads/details.aspx?
    FamilyId92F2A8F0-9243-4697-8F9A-FCF6BC9F66ABdisp
    laylangen
  • ASP.NET MVC Preview 3http//www.hanselman.com/blo
    g/ASPNETMVCPreview3.aspx
  • Quick Start Guideshttp//quickstarts.asp.net/3-5-
    extensions/mvc/default.aspx
  • Upcoming Changes in Routinghttp//haacked.com/arc
    hive/2008/04/10/upcoming-changes-in-routing.aspx
  • Scott Guthries Post on ASP.NET MVC
    Frameworkhttp//weblogs.asp.net/scottgu/archive/2
    007/10/14/asp-net-mvc-framework.aspx

26
Questions?
  • ASP.NET MVC is a new paradigm for .NET
    Developers a new way to think about programming
    web application.
  • Any Questions / Comments feel free to contact
    adnanmasood_at_gmail.com
  • Visit www.CodePlex.com/YABE
  • Visit www.AdnanMasood.com
Write a Comment
User Comments (0)
About PowerShow.com