First steps in ASP.NET MVC

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

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

Intermittent "Unable to read data from the transport connection: net_io_connectionclosed" errors

by John Avis | May 6, 2020

If you are having intermittent problems sending email in .NET using System.Net.Mail consider switching libraries.

500 Internal Server Error after migrating from IIS 7.5 to IIS 10

by John Avis | November 4, 2019

As support ends for Microsoft Windows Server 2008 I have recently gone through migrating some websites to a new server running Windows Server 2016 and IIS 10 but some of the websites did not work.

tagInput: A simple jQuery plugin for tag entry using Bootstrap 4

by John Avis | October 15, 2019

For a website project I needed a way to enter multiple tags. I just wanted something simple that I could easily modify to suit my own needs, so I wrote my own.


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

Leave a Comment



...random postings about web development and programming, Internet, computers and electronics topics.

I recommend ASPnix for web hosting and Crazy Domains for domain registration.


Get the latest posts delivered to your inbox.