In-Depth
Silverlight: What Web Forms Wanted to Be
ASP.NET Web Forms was ahead of its time. An ambitious attempt to make programming for the Web feel like programming for Windows, Microsoft introduced an innovative platform in January of 2002 that heavily abstracted the complexities of developing user interface elements with HTML and transformed Web development into an experience nearly indistinguishable from the complementary Windows Forms. Web Forms is a style of ASP.NET Web development designed to bring the familiar event-driven programming model of Visual Basic and Windows Forms applications to the Web. It unlocked the opportunities of Web development for the masses of existing client-application developers coming from a decade of Visual Basic. Almost.
The key problem that Web Forms had to solve: making a “stateless” development environment behave as if it had state. The Web is inherently “forgetful.” Once a server delivers a page, it forgets about it. This presents a challenge for line-of-business applications that often need to do some processing and redisplay a form while retaining changes made by the user.
Microsoft's Secret Sauce
Overcoming this forgetfulness in a standards-based way, relying on nothing but the Web’s traditional HTML and HTTP infrastructure, borders on magic. The underlying features that grant state to the Web might as well be magic for many Web developers. Microsoft created a complex processing system that included a secret sauce called “ViewState” to overcome the forgetful nature of Web servers toward the pages they serve. At the same time, Microsoft heavily abstracted developers away from the core technologies of the Web--HTML, CSS and JavaScript--and instead introduced a model that interpreted server markup to produce the needed output. Ultimately, Microsoft created a Web development platform tuned for line-of-business applications, and abstracted as much of “the Web” as possible without requiring custom browser software.
Unfortunately, the Web and magic do not mix. Eventually, Web applications must pay a price for the illusion they have the state that comes naturally to their desktop counterparts. As much as Web Forms tries, it cannot overcome the fact that it is operating in a stateless environment. While it goes a long way to close the gap between desktop and Web development, it never fully realizes the goal of making Web development feel like desktop development.
Does that mean Web Forms is a bad idea? Of course not! Businesses understand the value of applications that can be easily deployed and updated via the Web, avoiding the slow and resource-intensive process of building, testing, and deploying software to desktops. In a perfect world, businesses would be happy to take existing desktop applications, along with the associated “stateful” development model, and marry that to the Web’s simplified deployment. Web Forms tried, it just failed to go far enough.
Plug-in to a Rich Internet Experience
With nearly a decade of hindsight, Microsoft recognized that the only way to truly achieve the utopia businesses desired was to stop trying to work magic with the Web and instead build and deliver a plug-in that completely avoids the limits of browsers. Silverlight is the solution. A cross browser, cross platform plug-in, Silverlight is a Microsoft technology for building Rich Internet Applications using the popular .NET programming model and tools.
Silverlight is what Web Forms wanted to be, a stateful application development model that can be deployed and updated as easily as traditional Web sites. Unencumbered by the limits of stateless pages, developing for Silverlight finally achieves what ViewState could not: It allows traditional desktop application developers to reuse their skills and development patterns for applications that can be deployed with no installation, save for the Silverlight plug-in.
It also solves many of the other “problems” Web development creates for client application developers. With a consistent run-time not pegged to unpredictable browser implementations, Silverlight is able to deliver a consistent user experience without requiring days of extra testing and tweaking. The improved statefulness enables rich experiences often omitted in Web Forms applications, such as real-time field validation and error messages. Web Forms attempted to offer solutions to provide similar richness, but the perceived complexity of JavaScript, AJAX, and a host of other technologies needed to make it all come together often left time-strapped enterprise developers on the sidelines.
Browser and Desktop
It is clear that Silverlight is the natural successor to Web Forms, but its value extends beyond the original vision of Web Forms. Able to run out of the browser context and in absence of a network connection, Silverlight is arguably an up-and-coming replacement for traditional client application development, too. In all but the most unique applications, Silverlight’s capabilities make it a suitable replacement for apps that today may be built with Windows Forms or Windows Presentation Foundation (WPF).
With a single development and deployment model, Silverlight applications can target both browser-based and desktop use cases. Whereas Windows Forms and Web Forms require two distinct approaches to .NET application development, Silverlight allows developers to focus on mastering a single approach. If more evidence is needed to prove this is the future, examine the new Visual Studio LightSwitch from Microsoft. Targeted exclusively at simplifying line-of-business development, LightSwitch produces applications that can be deployed to the Web or desktop, and it uses Silverlight to produce both experiences.
Silverlight is not a silver bullet. It requires a software install to load the plug-in. With locked-down corporate networks, or devices such as Apple’s iPad, this software is inaccessible. In many ways, Silverlight is best viewed as a replacement for client application development and not a replacement for Web development. Even Web Forms is designed more to help with “client-like” application development than “pure” Web development. That point is reinforced by the recent introductions of ASP.NET variants, such as ASP.NET MVC, that move away from the simulated stateful programming model in Web Forms. For Web site development, or for applications where the Silverlight plug-in cannot absolutely be guaranteed, one of ASP.NET’s powerful variants is still the best choice for development.
Microsoft envisioned a world in 2002 where developing for the Web and Windows would be indistinguishable. Windows Forms and Web Forms tried to present a uniform approach, but ultimately Web Forms was bound by the limits of the Web and the vision was never fully realized.
With Silverlight, Microsoft’s vision is nearly complete. A single, unified programming model for building applications that run on the Web, desktop, and with the release of devices like Windows Phone 7, the emerging Internet-connected device, too. Web Forms and Silverlight will continue side-by-side long into the future, but for line-of-business applications, Silverlight has the momentum and Web Forms to thank for laying the foundation.
The opinions expressed here are those of the author and do not necessarily reflect the views of RedDevNews.com.
About the Author
Todd Anglin is Chief Evangelist for Telerik, a leading provider of development tools and UI components for .NET. Before joining Telerik, he worked for a large Fortune 200 financial services company where he learned the way of the “Enterprise” – big budgets, big projects, legacy systems, and incessant measurement. He now leverages this Enterprise experience to help Telerik make components that make the lives of all developers as easy as possible. Todd is an active author and speaker in the .NET community, focusing on web development technologies, a Microsoft MVP, founder and President of the North Houston .NET Users Group, and an O'Reilly author.