In the beginning, God (or Microsoft, you pick) created Active Server Pages or ASP. It allowed the server to dynamically generate web pages through the use of files containing a combination of VBScript and HTML.
At the time it was clever approach that allowed for a lot of flexibility, especially when used in conjunction with SQL Server to drive data.
However as the technology was pushed further and further, the code required to drive these sites became more convoluted and over time maintenance became more difficult. Great for those wanting to stay in a job, not so great for those coming in to clean it up. Trying to convince a new developer to jump into a 5+ year old ASP site is like getting Britney Spears on X Factor: a whole lot of time wasted and spending way more money than it’s worth.
But God (or Microsoft) must have been listening because lo and behold, ASP.Net arrived with the introduction of the .Net Framework. Now we can code with a strong language (kudos for getting C# so great on version 1) and are more easily able to organise design and code sensibly thanks to Web Forms.
During that time, a lot of work has gone into pushing design patterns and frameworks as these sites become more complex. One of these new frameworks was ASP.Net MVC.
I’ve been familiar with the Model View Controller pattern for a long time now. If I think it works for an application I’m developing I will definitely spend the time to make it right. However I wasn’t so sure about the ASP.Net version… to make it work within the confines of websites it seemed to require far more plumbing than I ever needed to do for applications which seemed wrong. So I left it for a time.
Then last year I had a chance to look at version 3 of ASP.Net MVC and I was impressed. A huge amount of work had been done to keep the plumbing down to a minimum. In addition, a new templating engine called “Razor” was introduced as an alternative to Web Forms.
Razor is very much a different beast to Web Forms… so much that it’s not really considered viable to try and share code between them. It’s an all or nothing approach. And this leads to the ultimate point of this post.
Just like ASP, Razor pages can consist of a mix of HTML and (in this case) C#/VB.Net mashed together in a manner that is not all that different from what was originally done and eventually frowned upon. Admittedly, having such a great languages at its core now makes the process far easier but it’s amusing to think that ASP may have been close to getting it right the first time.