Continuing onto Day 4 of my Migration to MVC 4 (Part 1, Part 2 and Part 3) contrary to what I suggested I would focus on last night, I dove into getting all of the MVC Routing in place so the site could start functioning like my existing WordPress site does. Having only been really doing MVC for a month in half in between MonoDroid, MonoTouch and Windows Phone I hadn't had time to really dive into Routing, which I had been excited about implementing in a future project. One of the first hurdles I ran into was leaving the default routing in place. Frustratingly this caused all of my new routes to not be processed correctly, keep that in mind when you first dive into MVC. For those also early on in their MVC Path, your routing is defined in the Global.asax.cs file. Your default route is defined in the RegisterRoutes function: [csharp] routes.MapRoute( name: "Default", url: "{controller}/{action}/{id}", defaults: new {controller = "Home", action = "Index", id = UrlParameter.Optional} ); [/csharp] If you were going to have a URL like this: [csharp] routes.MapRoute("PostsRoute", "{year}/{month}", new { controller = "Home", action = "Posts" }, new { year = @"\d+" }); [/csharp] I took it one step further by forcing the year parameter to be a number. To make use of the this route, just make sure your controller, Home has an ActionResult called Posts with both a year and month parameters like so: [csharp] public class HomeController : Controller { public ActionResult Posts(int year, string month) { .... } [/csharp] So now that the routing is working like I wanted tomorrow night is a focus on getting the content pages imported, routed and displayed properly. Being the planner I am, I figured I would map out the next few evenings:
  1. Tuesday - Content Pages (Import, Routing, Display)
  2. Wednesday - Comments (Import, Display, Adding)
  3. Thursday - Create the WCF Service Layer
  4. Friday - Add Login and Basic Add Post Form
  5. Sunday - Edit Post/Content Support