Developing database-driven websites using the ASP.NET Web Pages Framework, WebMatrix and Razor is not evil as most professional ASP.NET Web Developers might think. It is hard to look back on the 90's and Classic ASP websites with much optimism as ADO, millions of include files, and spaghetti code literally became the norm. Maintaining them was an utter nightmare in most cases.

This is a different time, however, and Microsoft.Data.dll is much better than ADO, the Razor Syntax is much better than VBScript, and a lot of the security concerns around Encoding, SQL Injection, proper validation, etc. are much more well-known and publicized than it was when Classic ASP first came on the scene. At the time, we also didn't have other frameworks, like WebForms and ASP.NET MVC, and other options for data access, like LINQ To SQL and Entity Framework, so we were pretty stuck making all kinds of crazy mistakes given there wasn't another avenue for more complicated websites.

WebMatrix, the ASP.NET Web Pages Framework with Razor, and Microsoft.Data.dll fit a particular need and development environment around simple, forms-over-data websites that are nothing more than a thin layer on top of a database. Personally, at this level, anything that attempts to abstract the fact that we are just pumping data from the database onto a web page is overcomplicating the issue and making the application more difficult to maintain.

As an example, take your typical Recent News or Recent Posts page on a personal website that literally pulls data from a single table based on either a publication date or id. I see no reason to create an ASP.NET MVC or WebForms website in Visual Studio with an O/R Mapper, Visual Designer, codebehind files, view model, a bloated web.config, and other nonsense when you can just take your favorite text editor and add a few lines of Razor syntax into a page in a few minutes with a much simpler deployment model.



This is far more easier to maintain than a similar application written with ASP.NET WebForms or ASP.NET MVC. Here we have 1 file that can easily be understood in any text editor with a clear understanding that this data is coming from a database using a particular query and dumped onto a web page. Want to sort it differently? Want to display more than 20 stories? It is pretty darn clear and pretty darn easy to make those changes and any changes that fit this simple, database-driven niche.

Other than those 3 lines at the top this looks pretty close to a view in the ASP.NET MVC Framework. If things get much more complicated and you need to offer a layer of abstraction and separate out concerns, you could move those 3 lines out of the view and migrate to MVC. I suspect such an application wouldn't grow to such a need, but if it does, there is a path to a more appropriate framework.

Also noticed that by default everything is HTML Encoded with less chance for JavaScript Injection. I have to work around the framework and use an HtmlString to display the body of the post to allow raw HTML to be displayed. We didn't have automatic encoding with Classic ASP :)

Although nothing is perfect and mistakes will be made by new developers, it won't be anything like the 90's and Classic ASP. This is good stuff for simple forms-over-data websites. As professional web developers I realize we worked long and hard to learn how to properly architect complex web applications, but I think the pendulum may have swung a bit too far and we forget the joy, ease, and beauty of developing simple websites using simple techniques and simple tools.