You are previewing ASP.NET MVC 4 Mobile App Development.
O'Reilly logo
ASP.NET MVC 4 Mobile App Development

Book Description

If your skill-sets include developing in C# on the .NET platform, this tutorial is a golden opportunity to extend your capabilities into mobile app development using the ASP.NET MVC framework. A totally practical primer.

  • Learn and utilize the latest Microsoft tools and technologies to develop mobile web apps with a native feel

  • Create web applications for the traditional and mobile web

  • Discover techniques used to overcome the pitfalls of developing Internet-ready apps

  • In Detail

    The ASP.NET MVC 4 framework is used to build scalable web applications with the help of design patterns and .NET Framework. The Model-View-Controller (MVC) is a design principle which separates the components of a web application. This separation helps you to modify, develop, and test different components of a web application.

    ASP.NET MVC 4 Mobile App Development helps you to develop next generation applications, while guiding you to deal with the constraints the mobile web places on application development. By the end of the book, you will be well versed with all the aspects of mobile app development.

    ASP.NET MVC 4 Mobile App Development introduces you to developing mobile web apps using the ASP.NET MVC 4 framework. Walking you through the process of creating a homebrew recipe sharing application, this book teaches you the fundamentals and concepts relevant to developing Internet-ready mobile-enabled web apps. Through the sample application, you will learn how to secure your apps against XSS and CSRF attacks, open up your application to users using third party logins such as Google or Facebook, and how to use Razor, HTML 5, and CSS 3 to create custom views and content targeting mobile devices. Using these custom views, you will then learn how to create web apps with a native mobile device feel using jQuery mobile. By the end of the book, you will be presented with a set of challenges to prove to yourself that you now have the skills to extend your existing web applications to the mobile web or create new mobile web apps.

    Table of Contents

    1. ASP.NET MVC 4 Mobile App Development
      1. Table of Contents
      2. ASP.NET MVC 4 Mobile App Development
      3. Credits
      4. About the Author
      5. Acknowledgment
      6. About the Reviewers
      7. www.PacktPub.com
        1. Support files, eBooks, discount offers and more
        2. Why Subscribe?
        3. Free Access for Packt account holders
        4. Instant Updates on New Packt Books
      8. Preface
        1. What this book covers
        2. What you need for this book
        3. Who this book is for
        4. Conventions
        5. Reader feedback
        6. Customer support
          1. Downloading the example code
          2. Errata
          3. Piracy
          4. Questions
      9. 1. Developing for the Mobile Web
        1. History of the mobile web
          1. The Nokia 9000
          2. Market fragmentation
          3. WAP 1.0 and WML
          4. WAP 2.0 and XHTML MP
        2. Continued development constraints
          1. Processing constraints
          2. Network constraints
            1. Content compression
              1. Server to client compression
              2. Minification
            2. Image optimizations
              1. Lower color depth
              2. CSS image sprites
              3. Data URIs
            3. Content Delivery Networks
              1. Cached data
              2. Less traffic
          3. Presentation constraints
            1. Single window
            2. Lower resolution
            3. Content spacing
        3. Viewing the mobile web
          1. Market percentage
          2. Browser variants and compatibility
            1. WebKit
            2. Trident
            3. Gecko
            4. Presto
          3. Emulating the mobile web
            1. Mobile device and browser emulators
              1. Opera
              2. Android
              3. iOS
              4. Windows Mobile
            2. The user agent
              1. Emulating Internet Explorer Mobile
              2. Emulating Mobile Safari
              3. Emulating Chrome for Mobile
              4. Emulation in this book
        4. Support for the mobile web in ASP.NET MVC 4
        5. Summary
      10. 2. Homebrew and You
        1. Understanding the homebrew domain
          1. Knowing your ingredients
            1. Malt
            2. Yeast
              1. Ale versus lager
              2. Hops
            3. Brewing
              1. Mashing
              2. Sparging
              3. The boil
            4. Fermentation
            5. Bottling and kegging
        2. About our mobile app
          1. App requirements
            1. Adding, editing, and deleting recipes
            2. Adding recipes to a library
            3. Rating recipes
            4. Commenting on recipes
            5. Anonymous browsing, authenticated contributing
        3. The BrewHow solution
          1. Creating the project
          2. Choosing our template
            1. The Empty template
            2. The Basic template
            3. The Internet Application template
            4. The Intranet Application template
            5. The Mobile Application template
            6. The Web API template
          3. Project changes in MVC 4
            1. NuGet
            2. Global.asax
          4. Launching the BrewHow app
            1. Responsive design
            2. Configuring and launching an emulator
        4. Summary
      11. 3. Introducing ASP.NET MVC 4
        1. The Model-View-Controller pattern
          1. The controller
          2. The view
          3. The model
        2. The MVC pattern and ASP.NET MVC 4
          1. Controllers in ASP.NET MVC
            1. Creating the Recipe controller
            2. Introduction to routing
            3. Action methods
            4. ActionResults
            5. Invoking the Recipe controller
          2. Views in ASP.NET MVC
            1. Razor
              1. The @ character
                1. Code blocks
                2. Expressions
                3. Inline code
                4. Comments
            2. Shared views
            3. Layouts
            4. The _ViewStart file
            5. Partial views
            6. HTML helpers
              1. Html.RenderPartial and Html.Partial
              2. Html.RenderAction and Html.Action
            7. Display templates
              1. Html.Display
              2. Html.DisplayFor
              3. Html.DisplayForModel
            8. Editor templates
            9. Creating our Recipe view
              1. Making Recipe default
          3. Returning a model to the view
            1. Using ViewData
            2. Using ViewBag
            3. Using TempData
            4. Strongly typed models
            5. Returning a Recipe list
              1. Creating the model
              2. Returning the model
              3. Displaying the model
        3. Summary
      12. 4. Modeling BrewHow in EF5
        1. What's new in Entity Framework 5.0?
          1. Performance enhancements
          2. LocalDB support
          3. Enumeration support
        2. The BrewHow model
          1. Modeling data
            1. Recipe
            2. Review
            3. Style
            4. Category
            5. The BrewHow context
          2. Generating our database
          3. Altering the model
            1. Adding relationships
            2. Overriding conventions
            3. Enabling migrations
              1. The InitialCreate migration
              2. The Configuration class
            4. Adding seed data
            5. Adding a migration
            6. Applying migrations
          4. Consuming the model
            1. Pagination
        3. Summary
      13. 5. The BrewHow Domain and Domain-driven Design
        1. Tenets of DDD
          1. Domain model
          2. Entities
          3. Value objects
          4. Aggregates
          5. Factories
          6. Repositories
          7. Services
        2. BrewHow design
          1. BrewHow entities
          2. BrewHow repositories
          3. Consuming the domain
            1. Recipe view model
              1. Data annotations
            2. Recipe controller
              1. GET versus POST
              2. Model binding
            3. Recipe views
        3. Summary
      14. 6. Writing Maintainable Code
        1. The SOLID principles
          1. Single Responsibility Principle
          2. Open Closed Principle
          3. Liskov Substitution Principle
          4. Interface Segregation Principle
          5. Dependency Inversion Principle
        2. SOLIDifying BrewHow
          1. Adding interfaces
            1. Infrastructure
          2. Dependency Injection
          3. Service locator
            1. Managed Extensibility Framework
              1. Convention-based configuration
            2. MEF Service Locator
              1. Using the MEF Service Locator
          4. Dependency Resolver
            1. The MefDependencyResolver class
          5. Completing the conversion
            1. IBrewHowContext
            2. Repositories
            3. Registering dependencies
        3. Summary
      15. 7. Separating Functionality Using Routes and Areas
        1. Routes
          1. Locating by style
            1. Routing constraints
            2. Style interaction
              1. Recipe list modification
              2. Style Controller and view
          2. Slugging BrewHow
            1. Model slugs
              1. Stage the database
              2. Modifying entities
              3. Retrieval by slug
        2. Areas
          1. Creating the review area
          2. Registering the Review area
          3. The Recipe review controller
            1. Recipe review view models
            2. Recipe review action methods
            3. Creating the views
            4. Area route values
            5. Routing namespaces
        3. Summary
      16. 8. Validating User Input
        1. Data validation
          1. Data annotations
            1. MetadataType attribute
            2. Updating the database
            3. Validating the validations
              1. Server validation
        2. Cross-Site Request Forgery (CSRF)
          1. ValidateAntiForgeryToken
        3. Cross-Site Scripting (XSS)
          1. ValidateInput attribute
          2. AllowHtml
          3. Html.Raw
        4. Summary
      17. 9. Identifying and Authorizing Users
        1. User authentication
          1. Windows authentication
          2. Forms authentication
        2. Authenticating BrewHow users
          1. SimpleMembership
          2. Customizing authentication
            1. SimpleMembership initialization
            2. Unifying contexts
            3. The UserProfile repository
            4. AccountController contexts
          3. Registering and logging in
          4. External authentication
            1. Registering with an external account
            2. Associating an external account
        3. Authorization
          1. Restricting access
            1. The Authorize attribute
            2. Authorizing user contributions
            3. Cleaning the UI
          2. Content ownership
            1. Enabling ownership
              1. UserProfile schema mapping
              2. Seeding users
              3. Applying the ownership migration
            2. Assigning ownership
            3. Enforcing ownership
              1. Adjusting the view model
              2. Ensuring ownership
              3. Validating ownership
          3. A recipe library
            1. The library data model
            2. The library repository
            3. The library controller
            4. The library view
        4. Summary
      18. 10. Asynchronous Programming and Bundles
        1. Asynchronous programming
          1. Task Parallel Library
            1. Task
              1. Creating a Task
              2. Awaiting completion
              3. Completion callbacks
          2. Async
          3. Await
          4. Asynchronous controller action methods
            1. Creating asynchronous actions
            2. An asynchronous recipe controller
        2. Bundles
          1. Creating bundles
            1. Bundle types
            2. Wildcard support
          2. Consuming bundles
        3. Summary
      19. 11. Coding for the Real-time Web
        1. Simulating a connected state
          1. Long polling
          2. Forever Frame
          3. Server-Sent Events
          4. WebSockets
        2. SignalR
          1. Persistent connections
          2. Hubs
        3. Real-time recipe updates
          1. Installing and configuring SignalR
          2. Creating the recipe hub
          3. Modifying the recipe list view
          4. Publishing event notifications
        4. Summary
      20. 12. Designing Your App for Mobile Devices
        1. HTML5
          1. Markup changes
            1. The DOCTYPE tag
            2. The character set
            3. Type attributes
            4. Visual Studio 2012 support
          2. Semantic tags
            1. The article tag
            2. The header tag
            3. The section tag
            4. The nav tag
            5. The footer tag
            6. Modifying recipe details
          3. Custom data attributes
          4. Form controls
          5. Local storage
          6. Geolocation
        2. CSS3
          1. Media types
          2. CSS selectors
            1. Type selectors
            2. ID selectors
            3. Attribute selectors
            4. Class selectors
            5. Universal selectors
            6. Pseudo-class selectors
          3. CSS media queries
            1. Media features
        3. The viewport meta tag
        4. A responsive design
          1. A responsive list
        5. Summary
      21. 13. Extending Support for the Mobile Web
        1. Mobile views
          1. A .Mobile layout
          2. Mobilizing BrewHow
            1. Removing content
            2. Prioritizing content
          3. How it works
        2. Display modes
          1. Supporting Asus Nexus 7
          2. Creating the display mode
          3. Registering the display mode
          4. Testing with Nexus 7
        3. Summary
      22. 14. Improving the User Experience with jQuery Mobile
        1. Installing jQuery Mobile
          1. Enabling the jQuery Mobile bundle
          2. Viewing the results
        2. jQuery Mobile's layout
          1. Data-roles and data attributes
          2. Form elements
          3. Themes
          4. $.mobile
          5. View switcher
        3. Mobilizing BrewHow
          1. Adjusting the header
            1. The home button
            2. Logging in users
            3. Site navigation
          2. Creating a footer
            1. Desktop footer
          3. Configuring content
            1. Recipe list
              1. The jQuery Mobile listview
              2. Expanded listview content
              3. Listview filters
              4. Buttons
              5. Navigation hints
            2. Recipe details
              1. Back button
              2. Action buttons
            3. Recipe edits
              1. Fieldcontain
            4. Reviews
              1. IsMobileDevice
              2. Mobile views
        4. Summary
      23. 15. Reader Challenges
        1. Full-text search
          1. Embedded search
            1. Search boxes
            2. APIs
          2. Lucene.NET
          3. SQL Server Full-text Search
        2. Socialization
          1. Social media support
            1. Recipe additions
            2. Recipe sharing
          2. Offline support
          3. Push notifications
        3. Going native
          1. ASP.NET Web API
          2. Developing native apps
            1. PhoneGap and Appcelerator
            2. Xamarin
        4. Summary
      24. Index