First steps in ASP.NET MVC

johna 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.

webpages-webforms-mvc

Related Posts

Web Development

How to set up a debugging using the Turnkey Linux LAMP stack and VS Code

by johna | December 19, 2023
The second part in my guide to setting up a website and database using the Turnkey Linux LAMP stack.

Website Hosting Web Development

How to set up a website and database using the Turnkey Linux LAMP stack

by johna | November 18, 2023
If you need to host your own website for the purposes of web development, Turnkey Linux LAMP Stack is an easy to install all-in-one solution that you can set up on a spare computer or a VM (Virtual Machine).

Web Development

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

by johna | May 6, 2020
If you are having intermittent problems sending email in .NET using System.Net.Mail consider switching libraries.

Comments

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

Leave a Comment

About

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

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

Subscribe

Get the latest posts delivered to your inbox.