Legacy ASP.NET Applications and ASP.NET MVC

I know it seems strange calling "traditional ASP.NET" legacy code now, but all the buzz is about ASP.NET MVC. One of the questions I have had is can I start replacing parts of my legacy site and not all of it. The answer is a resounding yes.

For this post, I am using the ASP.NET MVC Preview 3 release (1.0.30805.0), which was released a bit over a week ago. There is nothing really stellar here; I am just imparting something I have found.

Updating the Legacy Site

First, create a new site using the ASP.NET MVC bits. The template should be available in your projects after you install Preview 3. Then import a page you are currently using or create a page. Edit the site.master to include an <a href=""> this page (in my case, default.aspx in the customer folder), as follows:

<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="Site.master.cs" Inherits="Microtrak.Website.Views.Shared.Site" %>
<%@ Import Namespace="Microtrak.Website.Controllers" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title><%= Html.Encode(ViewData["Title"]) %></title>
    <link href="../../Content/Site.css" rel="stylesheet" type="text/css" />

    <div class="page">

        <div id="header">
            <p id="logo">
                <a href="">My Sample MVC Application</a>
            <ul id="menu">
                    <%= Html.ActionLink("Home", "Index", "Home")%>
                    <%= Html.ActionLink("About Us", "About", "Home")%>
                    <a href="../../customer/default.aspx">Customer</a>


        <div id="main">
            <div id="content">
                <asp:ContentPlaceHolder ID="MainContent" runat="server" />
            <div id="footer">
                    My Sample MVC Application &copy; Copyright 2008


Now, test it out. No problems hitting the page. The code runs fine. I am still in business.


The answer is simple. I want to move to MVC, but do not want to have to switch to big bang integration (all or nothing). This is being dictated by the sponsors of the project, who do not want a six month development cycle. Knowing I can use both MVC and standard ASP.NET, I am off to a bit of R&D.

On my list of things to do:

  1. Get both MVC and traditional ASP.NET working off the same sitemap – This is simple, on the surface, but the MVC must respect security trimmings, which is a point of contention for others that have gone down this path.
  2. Get Membership working. I would prefer my current custom provider, but I have the chance to make a few things sane in the project, so I may opt for a new provider, if it is simple. I have found a sample membership application on Code Plex by Troy Goode (www.squaredroot.com); this will likely be my starting point to get through this insanity. Hopefully, I can use the same algorithm as MS Membership so I can use the current database without alteration.
  3. Get themes working. According to Phil Haack, this is still working in MVC without any alterations, which is good for me.
  4. Get MapQuest working in MVC. This is one of the easiest tasks, as I already have the JavaScript encapsulated in a class. I should be able to spit this out into an MVC view without issue.

The rest is pretty much cake. And, the risk is fairly low, as I will have tests on all of the controllers, so any changes to the bits will be uncovered rather quickly.

Peace and Grace,


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: