State of ASP.NET part 2: One ASP.NET
ASP.NET has expanded into multiple code frameworks, including Web Forms, MVC and Web API. First these siblings grew apart, and now they’re coming back together.
There are two distinct developments a developer should take home from this. First, the unification of the Visual Studio project model helps you to mix these technologies in your projects. Second, the cross-pollination of features enriches all of these platforms. Now, I will look into each of these aspects further.
This blog post is the second part of my State of ASP.NET 2013 series. See the first part concerning the ship cycles.
Understanding the Core of ASP.NET
This diagram (courtesy of Scott Hanselman) is a simplified representation of the platform architecture. It doesn’t really reflect the technical relationships between the modules, but it conveys the key concept: there is a single platform under all the frameworks.
And what is this platform, then? When ASP.NET was born, the core was largely undistinguished from Web Forms. This wasn’t a technical truth, just a marketing one: Most demos concentrated on whipping up quick data entry forms, and it was only at the advent of MVC when the separation began to influence developer lives.
There is no one correct way to picture the ASP.NET Core.
On one hand, it is a collection of incredibly low-level technical structures and algorithms that handle communication and operations with IIS.
At the same time, the System.Web assembly has a multitude of powerful abstractions that support quite varying development scenarios. For example, the core supports user profiles and XML sitemaps as well as quite sophisticated caching.
The adjacent image is just one way to visualize what the ASP.NET core actually does, and it has its technical imperfections. But despite that, you can see, the notion of “One ASP.NET” actually does make sense.
Even though the diagram isn’t drawn to scale – i.e. the size of the boxes doesn’t represent the amount of functionality in each category – the frameworks we claim to use with zeal (“I would never touch Web Forms, MVC is so much better!”) have actually far more in common than one would quickly think.
One ASP.NET Project type
Perhaps the most practical incarnation of the One ASP.NET vision is combining all the project types into one. In Visual Studio 2013, there is Just One Project Type:
… but its selection is followed by this dialog:
You can now pick the multiple code frameworks to be supported. All the necessary configuration and directories will be done for you automatically.
You can also choose a template to get going quickly, but you don’t have to. In the preview stage the template options aren’t that diverse, but there is talk about letting 3rd parties to publish new project templates into this dialog.
The adjacent picture shows you the project setup generated by the settings above. As you can see, the Web API stuff dominates the resulting project structure – but you can throw in .aspx pages wherever you want.
Mixing the features
While it is now obvious that you can combine the various development approaches in a single project, the technologies have also grown closer to each other, primarily by Web Forms adopting features from ASP.NET MVC.
There are two paths here: First, features that originated within the new frameworks have trickled upstream into the ASP.NET core. Routing is a prime example, as it wholly originated within ASP.NET MVC. The second path is direct cloning of features: Model Binding in Web Forms is an excellent example of a feature that was invented in MVC, but then later ported over to Web Forms (and Web API).
Visual Studio 2013 also ships something for all these development models: a new scaffolding tool for ASP.NET, which enables you to quickly create code for all the code frameworks. In a web forms project, you would typically generate data manipulation pages for CRUD operations based on a class you already have – either handwritten or generated by a tool such as Entity Framework. For MVC and Web API projects, you’re most likely to scaffold out some controllers and views.
Of course, MVC and Web API build on top of the ASP.NET foundation laid by the years Microsoft spent developing Web Forms. Since Web Forms is now far less actively developed, it no longer contributes that many new ideas. But now, at the very least, it is both compatible and competitive with many of the other frameworks.
Putting them all together
The biggest hurdle to liberal mixing of these code frameworks isn’t technology. Rather, it is developer competence and attitudes.
I warmly recommend every developer to re-evaluate their views on ASP.NET. Every Microsoft web developer should know the most important three code frameworks, and a very easy approach is to do some quick tutorials.
Don’t just quickly leaf through them, but rather spend a while on each technology, and savor their current status and strengths. Don’t skip parts you think you know – of course you can connect a data source to a web site, but take a while to explore how Microsoft intends it to be done in year 2013. That enables you to understand the products and their tooling far more broadly.
And the key question is, of course: Looking back at the work you have done in recent months, what would you have done differently if you knew all these frameworks well?
Here are some of my recommendations for reading. Note that these tutorials are for VS2012, and thus don’t yet reflect the “One ASP.NET” project model . This should be fixed in a couple of months when VS2013 is out.
- Getting Started with ASP.NET 4.5 Web Forms: A trivially easy tutorial, but it explores many parts of modern Web Forms.
- Getting Started with ASP.NET MVC 4 is about the same in MVC. Reading this and the Web Forms tutorial side-by-side – it clearly illustrates how this technologies solve common problems such as model binding and validation.
- Build RESTful APIs with ASP.NET Web API goes through the basic hoops of using Web API.
- If you have the time, I would also recommend Getting Started with SignalR and MVC 4, which adds the realtime communications component into the mix.
Up next: What’s going on with the ASP.NET development tools?
[…] proyectos diferentes y herramientas exclusivas de la funcionalidad de cada proyecto. Ahora, con ONE ASP.NET se unifica la experiencia del proyecto web de manera que se pueden crear aplicaciones web ASP.NET […]