MVC4, Progressive Enhancement and MVVM

By Mike Hanson at February 15, 2013 17:04
Filed Under: .NET, MVC, Commentary

So I am “resting” again between contracts and have been getting stuck in to re-writing my Virtual Cycling community site www.vrcyclist.com with ASP.NET MVC4.  Apart from the obvious vrcyclist.com exists so that I have a public place to practice and show off my ASP.NET and web development skills.  It started out as a standard WebForms 1.0 site then progressed to ASP.NET Ajax and I even added a few new features using Silverlight.  Now with HTML5 becoming ever more prominent (even though it still isn’t a finished standard) I think it is time for a complete re-write, which provides me with an opportunity to morph it into a more general site for active people while retaining the existing functionality.

 

I’ve been learning MVC4 for a year or so now (I think I mentioned before when MVC and Silverlight were released around the same time I opted for throwing myself into Silverlight), which has made for a nice distraction from doing primarily Silverlight or WPF work for the last few years.

 

Kindle on my iPad is packed with books on ASP.NET MVC, HTML5, CSS3 and JavaScript that I have been using to bone up on relevant subjects and Progressive Enhancement struck me as pretty crucial for a modern web site/application.  I also noted the rise of KnockoutJS and the use of the MVVM pattern, which I like the idea of (being very familiar with it in my Silverlight and WPF work).  I’ve tinkered with several architectures/models/patterns for the new site and have settled on a pretty stable set work for me.  I’ve changed direction a few times and learned a lot of lessons in the process.  So I thought others might benefit from seeing what I have settled on and decided to write a series of blog posts to document it.  If nothing else I will have documented it for myself and demonstrated a grasp of MVC4 and other technologies to potential employers.

 

So to start I am just going to list the patterns and technologies I have settled on, which will at least provide a taster for what is to come and maybe tempt you back to read the follow up articles.

 

Back End/Middle Tier
  • ASP.NET MVC 4
    • AutoFac 3 (IoC container)
  • Entity Framework 5.0 (Code First and Migrations)
  • SQL Server 12
  • NLog
  • JavaScript Libraries
  • jQuery
  • jQuery UI
  • KnockouJS
  • log4javascript
  • HistoryJS
  • js-signals
  • Testing
  • NUnit – TDD Unit Tests
    • FluentAssertions
  • SpecFlow – BDD Acceptance Tests
  • SpecSalad
  • Telerik Testing Framework (Free) – UI Automation

 

Tools

Visual Studio 2012

ReSharper 7

NCrunch – Continuous Test

.NET Demon – Continuous Build

BitBucket – Source control repository

TortoiseHG – Source control client

VisualHG – IDE source control

NuGet – Package management

 

I won’t necessarily be covering usage of all the tools, but happy to answer any questions regarding usage or choices.

NLog MVC Integration

By Mike Hanson at April 05, 2012 19:23
Filed Under: .NET, Logging, NLog, MVC, DbContext, Code First, Migrations

Silverlight 2 and ASP.NET MVC showed their heads around the same time and despite all my experience developing with ASP.NET WebForms I jumped in the direction of Silverlight and missed the magic of MVC.  Recently I had the opportunity to work on a little MVC project and really enjoyed the experience.  Since then I have been working on re-writing a personal project, initially I started with MVC 3 but have since moved it up to 4.  I generally use NLog for logging and wanted to integrate it into my MVC project and wanted to use Entity Framework DbContext, Code First and Migrations.  I figured this might be something others would want to do so set about creating a little library to make it easy and fairly painless.  The project lives on github at https://github.com/MikeHanson/NLog.Mvc and includes the following:

 

  • A custom NLog Target that writes log entries to a database using a DbContext instance
  • A custom HandleErrorAttribute that logs exceptions via the NLog Target
  • A Logger utility class that you can instantiate or inject for other components to implement logging throughout your application.
  • I have documented NLog.Mvc within the project wiki at github,, but feel free to ask questions or give me feedback or event request features.  It is working as I need it to in my project, but I haven’t exhaustively tested in other scenarios.

Tag cloud

Previous Articles