First steps in ASP.NET MVC

John Avis by | October 11, 2012 | ASP.NET MVC

As I previously mentioned I have become a little irritated working in ASP.NET WebForms, due to the lack of control of final HTML markup, ViewState, it's limitations, the bloat generated, and the work-arounds you often have to do with ItemDataBound events, etc to accomplish simple things. So I have been looking at alternatives.

I have almost always worked in Microsoft development frameworks, aside from a brief foray in to PHP, but I recently bought a book on Ruby on Rails to see what the fuss was about. It didn't take too long reading about the multitude of packages that needed to be installed to develop and run websites, and the amount of text commands that need to be entered, and what appeared to be a lack of control over final HTML markup. I'll admit I haven't read much yet (and may never) so some of these conclusions may be wrong.

As a side note, Microsoft dropped MS-DOS a long time ago. How has Linux and related applications become so popular when you seem to have to resort to the command line for so many tasks? Admittedly I know next to nothing about Linux.

Anyway, many people say that MVC is the future (actually they have been saying it for some so the future is probably now) and it will change your life, so I thought I would give it a go. Reading books and tutorials didn't seem to help me too much so I thought I would launch straight in to rewriting a website in ASP.NET MVC3 that needed updating anyway.

After a few hours of reasonably successful work, my thoughts are that I'm not going to like MVC so much, and it may change my life but not necessarily for the better.

I've gone from Classic ASP (which I still love) where my code for each page is essentially in one place, to ASP.NET WebForms where my code is kind of separated into presentation and functionality with lots of work to try and make the two work together. Now with MVC my code is split up in to three areas: for each page I have to create a Model that is used to pass data from the Controller to the View, I have to create a Controller to handle the functionality and prepare the Model for the View, and then I create the View which although is meant to just be about presentation it needs to include various logic to do this.

And no matter what development environment then it is of course good practice to have more layers or tiers to handle data storage, or persistence as it is now called.

I appreciate that in larger team projects then it makes sense to split projects in to layers that different people or teams can develop separately, but most of the projects I work on I am either the sole developer or at most working in a small team, so I don't see the value in so much separation.

For me I think the best environment would be to work in ASP.NET Web Pages (Razor) which gives me Classic ASP-like top-to-bottom scripting, plus access to all the power of .NET like compilation, classes and all the internal namespaces. The main drawback of this seems to be the stigma associated with WebPages, as it is aimed at entry level programmers. It's still C# and you can still connect it with an OOP-type data persistence layer so the only thing entry level about it is that you can code a page with one file rather than two with WebForms (yes, I know you can do it in 1 file too), or about 21 files and folders (slight exageration) in MVC.

I will, however, persist further with MVC and see if my opinion changes over time.


Related Posts


How to view 'Entity Framework DbEntityValidation Exception was unhandled by user code' errors?

by John Avis | July 23, 2014

If you are using Entity Framework and have received this error message and have been frustrated by not being able to see what the actual problem is in Visual Studio then there is a simple solution.


There are no comments yet. Be the first to leave a comment!

Leave a Comment
ASP.NET Html Forms ASP.NET MVC ASP.NET Web Forms ASP.NET Web Pages Bootstrap C# Classic ASP Cool Websites Databases eBay and PayPal Electrical Repairs General Hardware HTML/CSS Jquery/Javascript Media Center Mobile Phones Responsive Web Design Reviews SEO and Social Networking Web Design Web Development Web Security web+db Website Hosting Windows XP Youtube

About me

...mostly about web development and programming, with a little bit of anything else related to the Internet, computers and technology.


Get the latest posts delivered to your inbox.