Skip to main content

Our Insights

The migration to ASP.NET Core MVC

Zak Dunstone

Maybe I’m only speaking for myself here, but I think the most exciting thing about working in this industry is the way in which it constantly changes. Here at LightMedia we are always discussing the latest trends, features and products so that we can improve our offering to our clients, and I’m here to briefly introduce our latest big shift:ASP.NET Core, and with it the beginning of a migration to MVC.

There are some great things about ASP.NET Core MVC that I can’t get enough of, but that does not make it all plain sailing. So my goal here is to give you a couple of fairly specific advantages and disadvantages of each style, from my perspective as a new ASP.NET Core MVC developer, and briefly touch on the business case for the change too.

What’s so great about ASP.NET Core MVC as opposed to Web Forms?

MVC solutions just feel slicker to use. I’ll admit, using postbacks and doing everything on the server side made it feel safe, contained and easy to work with as a developer. However that is just not good enough anymore for our users; it is no longer good enough for the whole page to refresh when you carry out any interactions with the webpage. Users demand a seamless, client-driven user experience and the MVC stack is much better at delivering that as it does not rely upon the ViewState.
Understanding the life cycle of Web Forms was, to put it lightly, a nightmare. Fair enough, it was simple to show/hide elements at the right point and handle some basic data binding, but dealing with complex validation, click events and postbacks all at the same time caused no end of headaches. Now, that process is simplified and following the web request through your application is an intuitive process.
Razor is a joy to work with! You regain complete control over the generated mark-up and can remove of those clunky “<% %>” tags that plague .aspx pages.

What do I miss from Web Forms?

One of the most satisfying things about Web Forms is perfecting a user control that can take care of its own data binding and mark-up (all depending on where it sits inside your project) and placing it wherever you like. This made life easy by:

Removing a lot of repetition from your code
Making your server-side code separated and readable: if the user control appeared on 15 different pages, then you wouldn’t have to have the data binding and logic in the code-behind of each page, because it could live in the code of your user control instead, allowing you to just make those changes once if you need to alter your logic.

Now, however, more work is required and, ultimately, we’re forced to repeat ourselves. Yes, MVC has “HTML partials” which can generate your client side code with no repetition, however the data binding no longer takes care of itself. So now if we want to show a specific piece of information on every page, then we must find a way to pass this data into every page as it loads, as well as carrying out the actions that are specific to that individual page too.

Sometimes the deadline is what is most important to our clients, and one of Web Forms’ selling points is how easily it allows for Rapid Application Development (RAD). As well as Web Forms being a quicker model in general, we already have so many solutions and products in Web Forms that we can modify and apply to any new situation that arises. Therefore when cost is the deciding factor, creating a smaller, cheaper web solution will still involve Web Forms.

So this transition to ASP.NET Core MVC will be an enjoyable one but will force us to start again and rethink a lot of our existing solutions – not a step that we take lightly.

What about the business decisions of changing toASP.NET Core MVC?

More often than not, clients care very little which technology their website is built in. As long as it does what they asked for, then they won’t mind whether it’s a WordPress site in PHP or a bespoke site using ASP.NET. Therefore saying to your manager that it will take longer (simply because you cannot copy and paste your old Web Forms code for a similar problem and have to learn a new way of doing things) might be a hard sell.

That being said, once you’ve taken the plunge and begun to create ASP.NET MVC solutions you will reap the benefits of staying up to date (Microsoft haven’t implemented Web Forms in the new ASP.NET Core) and enable your products take advantage of the latest security and performance updates.

I, for one, believe it’s the way to go and will make developing sites more enjoyable for us, as well as creating a better experience for our users.


Read other insights

Comments

No comments have been made on this article.


Use the form below to add your own comments:

Experts in a wide range of technologies...

Microsoft ASP.NET
Microsoft SQL Server
mongoDB
HTML 5 and CSS 3
Ajax
Rackspace
TeamCity
Node.js
Amazon Web Services
Microsoft Azure
AngularJS
Axure
jQuery
WCF
MVC