MSDN - ASP.NET MVC

Loading...

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

0 comments

Post a comment

    Post a comment
    Embed Video
    Edit your comment Cancel

    Favorites, Groups & Events

    MSDN - ASP.NET MVC - Presentation Transcript

    1. ASP.NET MVC (model-view-controller) Maarten Balliauw – RealDolmen http://blog.maartenballiauw.be
    2. Who am I?
      • Maarten Balliauw
      • Antwerp, Belgium
      • www.realdolmen.com
      • Focus on web
        • ASP.NET, ASP.NET MVC, PHP, Azure, VSTS, …
      • http://blog.maartenballiauw.be
      • http://twitter.com/maartenballiauw
    3. Agenda
      • Overview of ASP.NET
      • ASP.NET MVC
      • Building an application
      • Unit testing
      • Should I choose Webforms or MVC?
      • Q&A
    4. ASP.NET…
      • “ one web application framework to rule them all”
      • Always seen as one whole…
      ASP.NET Caching Modules Handlers Intrinsics Pages Controls Globalization Profile Master Pages Membership Roles Etc.
    5. Look at it differently!
      • Core infrastructure
      • Different presentation options
      Presentation Runtime ASP.NET Dynamic Data ASP.NET WebForms ASP.NET MVC ASP.NET Core
    6. ASP.NET MVC
      • A new presentation option for ASP.NET
      • Simpler way to program ASP.NET
      • Easily testable and TDD friendly
      • More control over your <html/>
      • More control over your URLs
      • Not for everyone! (car vs. motorcycle)
      • Not a replacement for webforms!
      • Supports existing ASP.NET features
    7. Things you will lose…
      • Viewstate
      • Postbacks
      • Tricky interview questions about nuances of the page lifecycle 
    8. MVC? Model-View-Controller! Separation of concerns! Controller (Input) Model (Logic) View (Presentation)
    9. What does an MVC request look like? Controller Handles input (HTTP requests) View Visually represents the model ViewData Request View Controller Response
    10. DEMO File > New…
    11. Framework Goals
      • Easy and frictionless testability
      • Full control over your <html/>
      • Full control over your URLs
      • Leverage existing ASP.NET features
      • Conventions and guidance
    12. Clean URLs
      • Would you use:
      • /Products.aspx?CategoryID={3F2504E0-4F89-11D3-9A0C-0305E82C3301}
      • Or:
      • /Products/Books
      My Favorite
    13. Extensibility
      • These come into play…
      • … and are all replacable!
      Controller Builder Controller Factory Controller View Engine View Controller Action Invoker Action Result Action Filters Model Binders
    14. DEMO
      • Building an ASP.NET MVC application
    15. Testing
      • Has anyone tried testing webforms?
      • Without IIS being fired up?
      • Each component tested individually?
      • Did you require vacation afterwards?
    16. Infrastructure designed for testing
      • These are all easily mockable!
        • HttpContextBase, HttpResponseBase, HttpRequestBase
      • Extensibility
        • IController
        • IControllerFactory
        • IRouteHandler
        • IViewEngine, IView
    17. Testing controller actions
      • No requirement to test within ASP.NET runtime!
        • Can mock parts of runtime you want to fake
        • Using Moq, Rhino, TypeMock, …
          • http://code.google.com/p/moq/
      [TestMethod] public void ShowPostsDisplayPostView() { BlogController controller = new BlogController(…); var result = controller.ShowPost(2) as ViewResult; Assert.IsNotNull(result); Assert.AreEqual(result.ViewData[ &quot; Message &quot; ], &quot; Hello &quot; ); }
    18. Testing controller actions using Moq
      • More on Mocking? Visit VISUG on May 7, 2009 – www.visug.be)
      [TestMethod] public void TestInvalidCredentials() { LoginController controller = new LoginController(); var mock = new Mock<System.Web.Security.MembershipProvider>(); mock.Expect(m => m.ValidateUser(&quot;&quot;, &quot;&quot;)).Returns(false); controller.MembershipProviderInstance = mock.Object; var result = controller.Authenticate(&quot;&quot;, &quot;&quot;) as ViewResult; Assert.IsNotNull(result); Assert.AreEqual(result.ViewName, &quot;Index&quot;); Assert.AreEqual(controller.ViewData[&quot;ErrorMessage&quot;], &quot;Invalid credentials! Please verify your username and password.&quot;); }
    19. Testing frameworks
      • Any framework is supported!
        • Visual Studio Test
        • NUnit
        • XUnit
        • MBUnit
    20. DEMO
      • Unit testing
    21. Choosing between Webforms and MVC
      • ASP.NET Webforms
      • Winforms-alike event model
      • Familiar controls
      • Familiar = rapid application development
      • Functionality per page
      • Uses viewstate for state management
      • Less control over rendered HTML
      • ASP.NET MVC
      • Less complex: separation of concerns
      • Easier parallel development
      • TDD support
      • No viewstate, …
      • Full control over behavior and HTML
      • Makes you think
    22. So what do I choose?
      • Go with the flow!
      • Remember: mixing of worlds is possible!
        • Mixing with ASP.NET Webforms
        • Mixing with dynamic data
    23. Takeaways
      • A new option for ASP.NET
        • Not a replacement for Webforms!
      • More control over your <html/> and URLs
      • Strong, frictionless testability
    24. Resources
      • “ ASP.NET MVC 1.0 Quickly” http://tinyurl.com/mvcquickly
      • My blog http://blog.maartenballiauw.be/category/MVC.aspx
      • Microsoft http://www.asp.net/mvc http://wiki.asp.net/page.aspx/286/aspnet-mvc-framework/
      • http://blog.wekeroad.com/blog/i-spose-ill-just-say-it-you-should-learn-mvc/
      • Community projects http://mvccontrib.codeplex.com http://mvcsitemap.codeplex.com
    25. Questions and Answers
      • http://blog.maartenballiauw.be
      • [email_address]
    26. © 2008 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

    + Maarten BalliauwMaarten Balliauw, 7 months ago

    custom

    2189 views, 0 favs, 5 embeds more stats

    Introduction to the ASP.NET MVC framework. (Belgium more

    More info about this document

    © All Rights Reserved

    Go to text version

    • Total Views 2189
      • 1980 on SlideShare
      • 209 from embeds
    • Comments 0
    • Favorites 0
    • Downloads 56
    Most viewed embeds
    • 196 views on http://blog.maartenballiauw.be
    • 6 views on http://cartrackr.codeplex.com
    • 3 views on http://www.codeplex.com
    • 3 views on http://www.realdolmenblogs.com
    • 1 views on http://reader.youdao.com

    more

    All embeds
    • 196 views on http://blog.maartenballiauw.be
    • 6 views on http://cartrackr.codeplex.com
    • 3 views on http://www.codeplex.com
    • 3 views on http://www.realdolmenblogs.com
    • 1 views on http://reader.youdao.com

    less

    Flagged as inappropriate Flag as inappropriate
    Flag as inappropriate

    Select your reason for flagging this presentation as inappropriate. If needed, use the feedback form to let us know more details.

    Cancel
    File a copyright complaint
    Having problems? Go to our helpdesk?

    Categories