My foray into .NET Core RTM and Angular

The rise of the web is upon us and has been for years. Ever since the release of .NET Core (which is pretty cool by the way!) I’ve been wanting to get into TypeScript and Angular. I’ve used a lot of MVC in the past in a .NET environment and there are some things that have always bothered me about ASP.NET MVC.

Mixed Code

How often did you end up with logic inside c(s)html files? It is just too easy (and to be quite honest, convenient) to put a few checks in views but it isn’t nice. What if you have a web developer in your site that isn’t familiar with C#/MVC? That person would be unable to properly work with your views.

This problem also causes a certain disconnect between client and server code. Views are rendered on the server (‘rendered’ as in converted to HTML) and sent back to the client. While the client only receives HTML in your web application you still have code in views. Wouldn’t it be ‘nicer’ to have it separated so there is a clear distinction between code your server should be executing and your client (granted, Razor is not executed on clients but it seems that way)?

I wonder if I’m the only one who gets this but with some systems and frameworks you just get a certain feeling. That feeling is, I think, a low level of programmer’s instinct in where things are better if they are cleaner and more distinctly organized. Systems where it feels like you understand the very basis of it, even though you may not have experience with it.

Those systems are usually well designed and expertly built systems, and you don’t see them as often as you’d like. I never really got that feeling with ASP.NET MVC. Yes, the Model – Controller bit is excellent but the interaction between Controller and the Views feels strange.

Servers

In ASP.NET MVC, you can’t really change your server. Your views are on there! While this is mostly not a disadvantage for MVC, and more an advantage for other frameworks, it is still very significant. To paint a picture; if you’re building a todo list in Angular/HTML/CSS (whether that’d be TypeScript or JavaScript), you’ll be interacting with your server through Ajax and you’ll be using JSON data. You couldn’t care less whether the framework serving that JSON is Python, Ruby, PHP or .NET. This is what I mean by distinctly organized; you’ll have your Angular and pages on the client side doing their thing, and you have a server serving up data through an API. This system feels nice.

What’s next with Angular

I still like ASP.NET MVC and I’d love to continue using it but I feel I’d do well diving into Angular and TypeScript. I’m always looking to better myself so..I guess it’s time to add another chapter to the book. I’m also not saying you shouldn’t be using ASP.NET MVC any longer, I’m just suggesting to open your eyes to other alternatives. Projects are completed with good solutions and that solution can mean any language or framework. Whatever suits the project best.

So, over the coming time I’ll probably be spending some time with this stuff and I’ll probably write about it here as well. The first few times I’ve set up Angular and TypeScript in ASP.NET MVC (this was during RC1 and 2 of .NET Core) it didn’t go too well. I got it all running but didn’t do much else with it at the time. Now, .NET Core is RTM and as such it is a great time to get going.

Leave a comment

Your email address will not be published. Required fields are marked *