In this episode of the Polymorphic Podcast Eric Hexter (@ehexter) and Jeffrey Palermo (@jeffreypalermo) join Craig Shoemaker (@craigshoemaker) to discuss Portable Areas. The Portable Areas contribution to MVC Contrib are an option for building single component or multi-page components for ASP.NET websites.
What Are Portable Areas?
- Encapsulates the UI functionality of a website and send messages to the application for data access, services, etc.
- Can be a single component on the page or come in form of multi-page feature to a site
- View logic and view markup are compiled into a single DLL for easy distribution
- An option for component model for MVC
- Feature of MVC Contrib
How Does a Portable Area Communicate with the Host Application?
- Registers on startup
- Sends messages in the form of a class to host application
- Messages managed by a ‘message bus’ which is a synchronous communication between area and app
How Is Integration Into the Application Handled?
- For single components, the view will access a HTML helper that in the end points to a controller and view result
- For multi-page components, new routes grants access to the new view pages
How Do the Areas Handle Layout and External Files?
- Layout is made consistent by leveraging MVC Framework’s use of default views that may be overridden in the application
- Documentation or review of embedded views will give developers of consuming apps the information about hooks required in views
- Images, CSS, and script files may be embedded into the DLL or added to the host application
What Are Some Examples?
The following are items Eric and Jeffrey mentioned as examples that are implemented as portable areas, or they would like to see as a portable area. This list will hopefully give you an idea of how and when to use this feature:
- ‘StackOverflow’ add-in
- Blog engine
- RSS reader
- ASP.Net MVC Portable Areas via MvcContrib
- Consuming a Portable Area with a Web Forms application
- ASP.NET MVC 2 In Action (Second Edition) on GitHub
- GitHub Repository for MVC Contrib